diff --git a/src/modules/misc.js b/src/modules/misc.js index 67e32ad..34bf7b2 100644 --- a/src/modules/misc.js +++ b/src/modules/misc.js @@ -74,22 +74,17 @@ wolfram.category = CATEGORY; wolfram.helpText = "Search YouTube and take the first result."; wolfram.usage = "<-v> [query]"; wolfram.addAlias("wa"); -wolfram.callback = async function (msg, line, verboseFlag, _query) { +wolfram.callback = async function (msg, line) { let verbose = false; - let query = _query; - - if (verboseFlag == "-v" && _query) { + if (line.includes("-v")) { + line = line.replace("-v", "").trim(); verbose = true; } - if (!_query) { - query = verboseFlag; - } - const req = await fetch( `http://api.wolframalpha.com/v2/query?input=${encodeURIComponent( - query + line )}&appid=LH2K8H-T3QKETAGT3&output=json` ).then((x) => x.json()); @@ -102,7 +97,7 @@ wolfram.callback = async function (msg, line, verboseFlag, _query) { if (verbose) { const embed = { - title: `Result for: \`${safeString(query)}\``, + title: `Result for: \`${safeString(line)}\``, color: getTopColor(msg, hf.bot.user.id, pastelize(hf.bot.user.id)), fields: [], footer: { @@ -129,7 +124,7 @@ wolfram.callback = async function (msg, line, verboseFlag, _query) { return {embed}; } else { - return `\`${safeString(query)}\` -> ${ + return `\`${safeString(line)}\` -> ${ data[1].subpods[0].plaintext.length > 0 ? safeString(data[1].subpods[0].plaintext) : data[1].subpods[0].img.src