misc: fix wolfram

This commit is contained in:
Cynthia Foxwell 2021-07-29 14:16:11 -06:00
parent 67db6a0173
commit 3822efc744

View file

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