mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
Add better error reporting to !reaction_roles clear
This commit is contained in:
parent
6427d9a5a9
commit
b3cebb3c25
1 changed files with 14 additions and 2 deletions
|
@ -1,7 +1,8 @@
|
||||||
import { reactionRolesCmd } from "../types";
|
import { reactionRolesCmd } from "../types";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||||
import { TextChannel } from "eris";
|
import { Message, TextChannel } from "eris";
|
||||||
|
import { isDiscordRESTError } from "../../../utils";
|
||||||
|
|
||||||
export const ClearReactionRolesCmd = reactionRolesCmd({
|
export const ClearReactionRolesCmd = reactionRolesCmd({
|
||||||
trigger: "reaction_roles clear",
|
trigger: "reaction_roles clear",
|
||||||
|
@ -20,7 +21,18 @@ export const ClearReactionRolesCmd = reactionRolesCmd({
|
||||||
|
|
||||||
pluginData.state.reactionRoles.removeFromMessage(args.message.messageId);
|
pluginData.state.reactionRoles.removeFromMessage(args.message.messageId);
|
||||||
|
|
||||||
const targetMessage = await args.message.channel.getMessage(args.message.messageId);
|
let targetMessage: Message<TextChannel>;
|
||||||
|
try {
|
||||||
|
targetMessage = await args.message.channel.getMessage(args.message.messageId);
|
||||||
|
} catch (err) {
|
||||||
|
if (isDiscordRESTError(err) && err.code === 50001) {
|
||||||
|
sendErrorMessage(pluginData, msg.channel, "Missing access to the specified message");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
await targetMessage.removeReactions();
|
await targetMessage.removeReactions();
|
||||||
|
|
||||||
sendSuccessMessage(pluginData, msg.channel, "Reaction roles cleared");
|
sendSuccessMessage(pluginData, msg.channel, "Reaction roles cleared");
|
||||||
|
|
Loading…
Add table
Reference in a new issue