commandDispatcher: convert embed to embeds, add addReactions
This commit is contained in:
parent
ff8d811ee3
commit
2577a7e847
1 changed files with 55 additions and 34 deletions
|
@ -82,41 +82,51 @@ async function CommandDispatcher(msg) {
|
||||||
|
|
||||||
const args = parseArguments(line);
|
const args = parseArguments(line);
|
||||||
|
|
||||||
const response = await runCommand(msg, cmd, line, args);
|
try {
|
||||||
if (response != null) {
|
const response = await runCommand(msg, cmd, line, args);
|
||||||
let file;
|
if (response != null) {
|
||||||
if (response.file) {
|
let file;
|
||||||
file = response.file;
|
if (response.file) {
|
||||||
delete response.file;
|
file = response.file;
|
||||||
}
|
delete response.file;
|
||||||
if (response.embeds) {
|
|
||||||
for (const embed of response.embeds) {
|
|
||||||
embed.color =
|
|
||||||
embed.color ||
|
|
||||||
getTopColor(msg, hf.bot.user.id, pastelize(hf.bot.user.id));
|
|
||||||
}
|
}
|
||||||
}
|
if (response.embed) {
|
||||||
if (response.reaction) {
|
response.embeds = [...(response.embeds ?? []), response.embed];
|
||||||
msg.addReaction(response.reaction);
|
}
|
||||||
} else {
|
if (response.embeds) {
|
||||||
msg.channel
|
for (const embed of response.embeds) {
|
||||||
.createMessage(
|
embed.color =
|
||||||
Object.assign(
|
embed.color ||
|
||||||
typeof response === "string" ? {content: response} : response,
|
getTopColor(msg, hf.bot.user.id, pastelize(hf.bot.user.id));
|
||||||
{
|
}
|
||||||
allowedMentions: {
|
}
|
||||||
repliedUser: false,
|
if (response.reaction) {
|
||||||
},
|
msg.addReaction(response.reaction);
|
||||||
messageReference: {
|
} else {
|
||||||
messageID: msg.id,
|
try {
|
||||||
},
|
const outMessage = await msg.channel.createMessage(
|
||||||
|
Object.assign(
|
||||||
|
typeof response === "string" ? {content: response} : response,
|
||||||
|
{
|
||||||
|
allowedMentions: {
|
||||||
|
repliedUser: false,
|
||||||
|
},
|
||||||
|
messageReference: {
|
||||||
|
messageID: msg.id,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
),
|
||||||
|
file
|
||||||
|
);
|
||||||
|
if (response.addReactions) {
|
||||||
|
for (const index in response.addReactions) {
|
||||||
|
const reaction = response.addReactions[index];
|
||||||
|
await outMessage.addReaction(reaction);
|
||||||
}
|
}
|
||||||
),
|
}
|
||||||
file
|
} catch (err) {
|
||||||
)
|
|
||||||
.catch((e) => {
|
|
||||||
msg.channel.createMessage({
|
msg.channel.createMessage({
|
||||||
content: `:warning: An error has occurred:\n\`\`\`${e}\`\`\``,
|
content: `:warning: An error has occurred:\n\`\`\`${err}\`\`\``,
|
||||||
allowedMentions: {
|
allowedMentions: {
|
||||||
repliedUser: false,
|
repliedUser: false,
|
||||||
},
|
},
|
||||||
|
@ -124,9 +134,20 @@ async function CommandDispatcher(msg) {
|
||||||
messageID: msg.id,
|
messageID: msg.id,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
}
|
||||||
|
msg.hasRan = true;
|
||||||
}
|
}
|
||||||
msg.hasRan = true;
|
} catch (err) {
|
||||||
|
msg.channel.createMessage({
|
||||||
|
content: `:warning: An error has occurred:\n\`\`\`${err}\`\`\``,
|
||||||
|
allowedMentions: {
|
||||||
|
repliedUser: false,
|
||||||
|
},
|
||||||
|
messageReference: {
|
||||||
|
messageID: msg.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue