various fixes

This commit is contained in:
Erik 2021-06-19 23:41:51 +03:00
parent b0ba34b1ac
commit 8634a64107
No known key found for this signature in database
GPG Key ID: 7E862371D3409F16
8 changed files with 68 additions and 8 deletions

View File

@ -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,

View File

@ -11,7 +11,7 @@ class CannedReply extends Command {
});
}
async execute(message, args) {
async execute(message, { args }) {
const [first] = args.map((a) => a);
// eslint-disable-next-line prefer-const

View 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;

View File

@ -11,7 +11,7 @@ class Logs extends Command {
});
}
async execute(message, args) {
async execute(message, { args }) {
const user = await this.client.resolveUser(args[0]);
let pageNr = 1;

View File

@ -8,7 +8,7 @@ class Markread extends Command {
});
}
async execute(message, args) {
async execute(message) {
return this.client.modmail.markread(message);

View File

@ -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);

View File

@ -8,6 +8,10 @@ class Ping extends Command {
});
}
execute() {
return `PONG!`;
}
}
module.exports = Ping;

View File

@ -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