commandDispatcher: handle errors

This commit is contained in:
Cynthia Foxwell 2021-05-27 15:18:51 -06:00
parent cc4d882d7a
commit 0de8b61ddb

View file

@ -83,20 +83,32 @@ async function CommandDispatcher(msg) {
const response = await runCommand(msg, cmd, line, args); const response = await runCommand(msg, cmd, line, args);
if (response != null) { if (response != null) {
msg.channel.createMessage( msg.channel
Object.assign( .createMessage(
typeof response === "string" ? {content: response} : response, Object.assign(
{ typeof response === "string" ? {content: response} : response,
{
allowedMentions: {
repliedUser: false,
},
messageReference: {
messageID: msg.id,
},
}
),
response.file
)
.catch((e) => {
msg.channel.createMessage({
content: `:warning: An error has occurred:\n\`\`\`${e}\`\`\``,
allowedMentions: { allowedMentions: {
repliedUser: false, repliedUser: false,
}, },
messageReference: { messageReference: {
messageID: msg.id, messageID: msg.id,
}, },
} });
), });
response.file
);
} }
msg.hasRan = true; msg.hasRan = true;
} }