bugfix to listing canned responses

This commit is contained in:
Erik 2021-11-29 15:38:37 +02:00
parent c09dba2f41
commit c63f41beed
No known key found for this signature in database
GPG Key ID: FEFF4B220DDF5589
2 changed files with 7 additions and 6 deletions

View File

@ -117,8 +117,8 @@ class ModmailClient extends Client {
this.logger.debug(`${message.author.tag} is executing command ${command.name}`); this.logger.debug(`${message.author.tag} is executing command ${command.name}`);
const clean = message.content.replace(`${this.prefix}${commandName}`, '').trim(); const clean = message.content.replace(`${this.prefix}${commandName}`, '').trim();
const result = await command.execute(message, { args, clean }).catch((err) => { const result = await command.execute(message, { args: [ ...args ], clean }).catch((err) => {
this.logger.error(`Command ${command.name} errored during execution:\nARGS: [${args.join(', ')}]\n${err.stack}`); this.logger.error(`Command ${command.name} errored during execution:\nARGS: [ "${args.join('", "')}" ]\n${err.stack}`);
return { return {
error: true, error: true,
msg: `Command ${command.name} ran into an error during execution. This has been logged.` msg: `Command ${command.name} ran into an error during execution. This has been logged.`

View File

@ -30,13 +30,14 @@ class CannedReply extends Command {
let str = ''; let str = '';
// eslint-disable-next-line no-shadow // eslint-disable-next-line no-shadow
for (const [ name, content ] of list) { for (const [ name, content ] of list) {
if (str.length + content.length > 2000) { const substr = `**${name}:** ${content}\n`;
await channel.send(str); // .catch(err => this.client.logger.error(`CannedReply.execute errored at channel.send:\n${err.stack}`)); if (str.length + substr.length > 2000) {
await channel.send(str);
str = ''; str = '';
} }
str += `**${name}:** ${content}\n`; str += substr;
} }
if (str.length) return channel.send(str); // .catch(err => this.client.logger.error(`CannedReply.execute errored at channel.send:\n${err.stack}`)); if (str.length) return channel.send(str);
return '**__None__**'; return '**__None__**';
} }
return this.client.modmail.sendCannedResponse({ message, responseName: content.trim(), anon }); return this.client.modmail.sendCannedResponse({ message, responseName: content.trim(), anon });