-
Notifications
You must be signed in to change notification settings - Fork 0
/
eval.ts
29 lines (27 loc) · 708 Bytes
/
eval.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { User } from './classes';
import * as db from './db';
import { commands } from './commands';
// This file serves the purpose that it makes it easier for the server owner / an admin
// to manually change data. A decent knowledge and understanding of the source code is required
commands.on(
{
name: 'eval',
filters: discord.command.filters.isAdministrator()
},
(args) => ({
code: args.text()
}),
async (message, { code }) => {
code = code.replace(/\`\`\`.*\n*/g, '');
try {
var evaled = await eval(code);
await message.reply(`\`\`\`js
${JSON.stringify(evaled)}
\`\`\``);
} catch (err) {
await message.reply(`\`\`\`js
${err}
\`\`\``);
}
}
);