various fixes
This commit is contained in:
parent
b0ba34b1ac
commit
8634a64107
@ -116,7 +116,7 @@ class ModmailClient extends Client {
|
||||
}
|
||||
|
||||
this.logger.debug(`Executing command ${command.name}`);
|
||||
const result = await command.execute(message, args).catch((err) => {
|
||||
const result = await command.execute(message, { args, clean: message.content.replace(`${this.prefix}${commandName}`, '').trim() }).catch((err) => {
|
||||
this.logger.error(`Command ${command.name} errored during execution:\n${err.stack}`);
|
||||
return {
|
||||
error: true,
|
||||
|
@ -11,8 +11,8 @@ class CannedReply extends Command {
|
||||
});
|
||||
}
|
||||
|
||||
async execute(message, args) {
|
||||
|
||||
async execute(message, { args }) {
|
||||
|
||||
const [first] = args.map((a) => a);
|
||||
// eslint-disable-next-line prefer-const
|
||||
let { channel, content, _caller } = message,
|
||||
|
56
structure/commands/Eval.js
Normal file
56
structure/commands/Eval.js
Normal file
@ -0,0 +1,56 @@
|
||||
const { inspect } = require('util');
|
||||
const { username } = require('os').userInfo();
|
||||
|
||||
const Command = require('../Command');
|
||||
|
||||
class Eval extends Command {
|
||||
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'eval',
|
||||
aliases: ['e']
|
||||
});
|
||||
}
|
||||
|
||||
async execute(message, { clean }) {
|
||||
|
||||
const { guild, author, member, client } = message; //eslint-disable-line no-unused-vars
|
||||
|
||||
try {
|
||||
let evaled = eval(clean); //eslint-disable-line no-eval
|
||||
if (evaled instanceof Promise) await evaled;
|
||||
if (typeof evaled !== 'string') evaled = inspect(evaled);
|
||||
|
||||
evaled = evaled
|
||||
.replace(new RegExp(this.client.token, 'gu'), '<redacted>')
|
||||
.replace(new RegExp(username, 'gu'), '<redacted>');
|
||||
|
||||
//if (args.log) guild._debugLog(`[${message.author.tag}] Evaluation Success: ${evaled}`);
|
||||
|
||||
if (evaled.length > 1850) {
|
||||
evaled = `${evaled.substring(0, 1850)}...`;
|
||||
}
|
||||
await message.respond(
|
||||
`Evaluation was successful.\`\`\`js\n${evaled}\`\`\``,
|
||||
{ emoji: 'success' }
|
||||
);
|
||||
|
||||
|
||||
} catch (error) {
|
||||
|
||||
let msg = `${error}${error.stack ? `\n${error.stack}` : ''}`;
|
||||
|
||||
//if (args.log) guild._debugLog(`[${message.author.tag}] Evaluation Fail: ${msg}`);
|
||||
if (msg.length > 2000) msg = `${msg.substring(0, 1900)}...`;
|
||||
await message.respond(
|
||||
`Evaluation failed.\`\`\`js\n${msg}\`\`\``,
|
||||
{ emoji: 'failure' }
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Eval;
|
@ -11,8 +11,8 @@ class Logs extends Command {
|
||||
});
|
||||
}
|
||||
|
||||
async execute(message, args) {
|
||||
|
||||
async execute(message, { args }) {
|
||||
|
||||
const user = await this.client.resolveUser(args[0]);
|
||||
let pageNr = 1;
|
||||
if (args[1]) {
|
||||
|
@ -8,7 +8,7 @@ class Markread extends Command {
|
||||
});
|
||||
}
|
||||
|
||||
async execute(message, args) {
|
||||
async execute(message) {
|
||||
|
||||
return this.client.modmail.markread(message);
|
||||
|
||||
|
@ -11,7 +11,7 @@ class Modmail extends Command {
|
||||
});
|
||||
}
|
||||
|
||||
async execute(message, args) {
|
||||
async execute(message, { args }) {
|
||||
|
||||
// eslint-disable-next-line prefer-const
|
||||
let [first, second] = args.map((a) => a);
|
||||
|
@ -8,6 +8,10 @@ class Ping extends Command {
|
||||
});
|
||||
}
|
||||
|
||||
execute() {
|
||||
return `PONG!`;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Ping;
|
@ -11,7 +11,7 @@ class Reply extends Command {
|
||||
});
|
||||
}
|
||||
|
||||
async execute(message, args) {
|
||||
async execute(message, { args }) {
|
||||
|
||||
const [first] = args.map((a) => a);
|
||||
// eslint-disable-next-line prefer-const
|
||||
|
Loading…
Reference in New Issue
Block a user