commandDispatcher: add support for sending a reaction instead of a message

This commit is contained in:
Cynthia Foxwell 2021-05-27 16:45:56 -06:00
parent 97206cb213
commit b176fe8184
1 changed files with 23 additions and 19 deletions

View File

@ -88,32 +88,36 @@ async function CommandDispatcher(msg) {
file = response.file;
delete response.file;
}
msg.channel
.createMessage(
Object.assign(
typeof response === "string" ? {content: response} : response,
{
if (response.reaction) {
msg.addReaction(response.reaction);
} else {
msg.channel
.createMessage(
Object.assign(
typeof response === "string" ? {content: response} : response,
{
allowedMentions: {
repliedUser: false,
},
messageReference: {
messageID: msg.id,
},
}
),
file
)
.catch((e) => {
msg.channel.createMessage({
content: `:warning: An error has occurred:\n\`\`\`${e}\`\`\``,
allowedMentions: {
repliedUser: false,
},
messageReference: {
messageID: msg.id,
},
}
),
file
)
.catch((e) => {
msg.channel.createMessage({
content: `:warning: An error has occurred:\n\`\`\`${e}\`\`\``,
allowedMentions: {
repliedUser: false,
},
messageReference: {
messageID: msg.id,
},
});
});
});
}
}
msg.hasRan = true;
}