Compare commits
2 Commits
8093224c46
...
69a8452574
Author | SHA1 | Date |
---|---|---|
Alyxia Sother | 69a8452574 | |
Alyxia Sother | 78f3490003 |
File diff suppressed because it is too large
Load Diff
|
@ -21,13 +21,12 @@
|
|||
"figlet": "^1.5.2",
|
||||
"glob": "^7.2.0",
|
||||
"inquirer": "^8.2.0",
|
||||
"mathjs": "^9.5.1",
|
||||
"moment": "^2.29.1",
|
||||
"ms": "^2.1.3",
|
||||
"node-wolfram-alpha": "^1.2.5",
|
||||
"onion-lasers": "npm:onion-lasers-v13@^2.1.0",
|
||||
"pet-pet-gif": "^1.0.9",
|
||||
"relevant-urban": "^2.0.0",
|
||||
"translate-google": "^1.5.0",
|
||||
"weather-js": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -1,24 +1,34 @@
|
|||
import {NamedCommand, RestCommand} from "onion-lasers";
|
||||
import * as math from "mathjs";
|
||||
import {WolframClient} from "node-wolfram-alpha";
|
||||
import {MessageEmbed} from "discord.js";
|
||||
import {Config} from "../../structures";
|
||||
|
||||
export default new NamedCommand({
|
||||
description: "Calculates a specified math expression.",
|
||||
run: "Please provide a calculation.",
|
||||
any: new RestCommand({
|
||||
async run({send, combined}) {
|
||||
if (Config.wolfram === null) return send("There's no Wolfram token in the config.");
|
||||
|
||||
const wClient = new WolframClient(Config.wolfram);
|
||||
let resp;
|
||||
try {
|
||||
resp = math.evaluate(combined);
|
||||
} catch (e) {
|
||||
return send("Please provide a *valid* calculation.");
|
||||
resp = await wClient.query(combined);
|
||||
} catch (e: any) {
|
||||
return send("Something went wrong.");
|
||||
}
|
||||
|
||||
if (!resp.data.queryresult.pods) return send("No pods were returned. Your query was likely invalid.");
|
||||
else {
|
||||
// TODO: Please don't hardcode the pod to fetch, try to figure out
|
||||
// which is the right one based on some comparisons instead
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0xffffff)
|
||||
.setTitle("Math Calculation")
|
||||
.addField("Input", `\`\`\`\n${combined}\`\`\``)
|
||||
.addField("Output", `\`\`\`\n${resp.data.queryresult.pods[1].subpods[0].plaintext}\`\`\``);
|
||||
return send({embeds: [embed]});
|
||||
}
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0xffffff)
|
||||
.setTitle("Math Calculation")
|
||||
.addField("Input", `\`\`\`js\n${combined}\`\`\``)
|
||||
.addField("Output", `\`\`\`js\n${resp}\`\`\``);
|
||||
return send({embeds: [embed]});
|
||||
}
|
||||
})
|
||||
});
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
import {Command, NamedCommand, RestCommand} from "onion-lasers";
|
||||
import translate from "translate-google";
|
||||
|
||||
export default new NamedCommand({
|
||||
description: "Translates your input.",
|
||||
usage: "<lang ID> <input>",
|
||||
run: "You need to specify a language to translate to.",
|
||||
any: new Command({
|
||||
run: "You need to enter some text to translate.",
|
||||
any: new RestCommand({
|
||||
async run({send, args}) {
|
||||
const lang = args[0];
|
||||
const input = args.slice(1).join(" ");
|
||||
translate(input, {
|
||||
to: lang
|
||||
})
|
||||
.then((res) => {
|
||||
send({
|
||||
embeds: [
|
||||
{
|
||||
title: "Translation",
|
||||
fields: [
|
||||
{
|
||||
name: "Input",
|
||||
value: `\`\`\`${input}\`\`\``
|
||||
},
|
||||
{
|
||||
name: "Output",
|
||||
value: `\`\`\`${res}\`\`\``
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("[translate]", error);
|
||||
send(
|
||||
`${error}\nPlease use the following list: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes`
|
||||
);
|
||||
});
|
||||
}
|
||||
})
|
||||
})
|
||||
});
|
|
@ -1,9 +0,0 @@
|
|||
interface TranslateOptions {
|
||||
from?: string;
|
||||
to?: string;
|
||||
}
|
||||
|
||||
declare module "translate-google" {
|
||||
function translate(input: string, options: TranslateOptions): Promise<string>;
|
||||
export = translate;
|
||||
}
|
|
@ -14,6 +14,7 @@ class ConfigStructure extends GenericStructure {
|
|||
public admins: string[];
|
||||
public support: string[];
|
||||
public lavalink: boolean | null;
|
||||
public wolfram: string | null;
|
||||
public systemLogsChannel: string | null;
|
||||
public webhooks: {[id: string]: string}; // id-token pairs
|
||||
|
||||
|
@ -25,6 +26,7 @@ class ConfigStructure extends GenericStructure {
|
|||
this.admins = select(data.admins, [], String, true);
|
||||
this.support = select(data.support, [], String, true);
|
||||
this.lavalink = select(data.lavalink, null, Boolean);
|
||||
this.wolfram = select(data.wolfram, null, String);
|
||||
this.systemLogsChannel = select(data.systemLogsChannel, null, String);
|
||||
this.webhooks = {};
|
||||
|
||||
|
|
Loading…
Reference in New Issue