From c63f41beedc14a3e34a3c491edc0a748d0a7e924 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Mon, 29 Nov 2021 15:38:37 +0200 Subject: [PATCH] bugfix to listing canned responses --- structure/Client.js | 4 ++-- structure/commands/CannedReply.js | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/structure/Client.js b/structure/Client.js index c249a63..1c918c5 100644 --- a/structure/Client.js +++ b/structure/Client.js @@ -117,8 +117,8 @@ class ModmailClient extends Client { this.logger.debug(`${message.author.tag} is executing command ${command.name}`); const clean = message.content.replace(`${this.prefix}${commandName}`, '').trim(); - const result = await command.execute(message, { args, clean }).catch((err) => { - this.logger.error(`Command ${command.name} errored during execution:\nARGS: [${args.join(', ')}]\n${err.stack}`); + 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}`); return { error: true, msg: `Command ${command.name} ran into an error during execution. This has been logged.` diff --git a/structure/commands/CannedReply.js b/structure/commands/CannedReply.js index 00d476b..9c56316 100644 --- a/structure/commands/CannedReply.js +++ b/structure/commands/CannedReply.js @@ -30,13 +30,14 @@ class CannedReply extends Command { let str = ''; // eslint-disable-next-line no-shadow for (const [ name, content ] of list) { - if (str.length + content.length > 2000) { - await channel.send(str); // .catch(err => this.client.logger.error(`CannedReply.execute errored at channel.send:\n${err.stack}`)); + const substr = `**${name}:** ${content}\n`; + if (str.length + substr.length > 2000) { + await channel.send(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 this.client.modmail.sendCannedResponse({ message, responseName: content.trim(), anon });