mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
Better reaction role errors (2)
This commit is contained in:
parent
b53acd6b84
commit
60f73bd752
1 changed files with 12 additions and 6 deletions
|
@ -3,7 +3,7 @@ import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||||
import { TextChannel } from "eris";
|
import { TextChannel } from "eris";
|
||||||
import { RecoverablePluginError, ERRORS } from "src/RecoverablePluginError";
|
import { RecoverablePluginError, ERRORS } from "src/RecoverablePluginError";
|
||||||
import { canUseEmoji, noop } from "../../../utils";
|
import { canUseEmoji, isDiscordRESTError, noop } from "../../../utils";
|
||||||
import { applyReactionRoleReactionsToMessage } from "../util/applyReactionRoleReactionsToMessage";
|
import { applyReactionRoleReactionsToMessage } from "../util/applyReactionRoleReactionsToMessage";
|
||||||
import { canReadChannel } from "../../../utils/canReadChannel";
|
import { canReadChannel } from "../../../utils/canReadChannel";
|
||||||
|
|
||||||
|
@ -22,14 +22,20 @@ export const InitReactionRolesCmd = reactionRolesCmd({
|
||||||
|
|
||||||
async run({ message: msg, args, pluginData }) {
|
async run({ message: msg, args, pluginData }) {
|
||||||
if (!canReadChannel(args.message.channel, msg.member)) {
|
if (!canReadChannel(args.message.channel, msg.member)) {
|
||||||
sendErrorMessage(pluginData, msg.channel, "Unknown message");
|
sendErrorMessage(pluginData, msg.channel, "You can't add reaction roles to channels you can't see yourself");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const targetMessage = await args.message.channel.getMessage(args.message.messageId);
|
let targetMessage;
|
||||||
if (!targetMessage) {
|
try {
|
||||||
sendErrorMessage(pluginData, msg.channel, "Unknown message (2)");
|
targetMessage = await args.message.channel.getMessage(args.message.messageId).catch(noop);
|
||||||
return;
|
} catch (e) {
|
||||||
|
if (isDiscordRESTError(e)) {
|
||||||
|
sendErrorMessage(pluginData, msg.channel, `Error ${e.code} while getting message: ${e.message}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear old reaction roles for the message from the DB
|
// Clear old reaction roles for the message from the DB
|
||||||
|
|
Loading…
Add table
Reference in a new issue