mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-16 22:21:51 +00:00
Fix crash in ReactionRoles emoji validation
This commit is contained in:
parent
400f1f0807
commit
fde796782e
2 changed files with 16 additions and 16 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 "../../../RecoverablePluginError";
|
import { RecoverablePluginError, ERRORS } from "../../../RecoverablePluginError";
|
||||||
import { canUseEmoji, isDiscordRESTError, noop } from "../../../utils";
|
import { canUseEmoji, isDiscordRESTError, isValidEmoji, noop } from "../../../utils";
|
||||||
import { applyReactionRoleReactionsToMessage } from "../util/applyReactionRoleReactionsToMessage";
|
import { applyReactionRoleReactionsToMessage } from "../util/applyReactionRoleReactionsToMessage";
|
||||||
import { canReadChannel } from "../../../utils/canReadChannel";
|
import { canReadChannel } from "../../../utils/canReadChannel";
|
||||||
|
|
||||||
|
@ -69,22 +69,18 @@ export const InitReactionRolesCmd = reactionRolesCmd({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
if (!isValidEmoji(pair[0])) {
|
||||||
if (!canUseEmoji(pluginData.client, pair[0])) {
|
sendErrorMessage(pluginData, msg.channel, `Invalid emoji: ${pair[0]}`);
|
||||||
sendErrorMessage(
|
return;
|
||||||
pluginData,
|
}
|
||||||
msg.channel,
|
|
||||||
"I can only use regular emojis and custom emojis from servers I'm on",
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
if (e instanceof RecoverablePluginError && e.code === ERRORS.INVALID_EMOJI) {
|
|
||||||
sendErrorMessage(pluginData, msg.channel, `Invalid emoji: ${pair[0]}`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw e;
|
if (!canUseEmoji(pluginData.client, pair[0])) {
|
||||||
|
sendErrorMessage(
|
||||||
|
pluginData,
|
||||||
|
msg.channel,
|
||||||
|
"I can only use regular emojis and custom emojis from servers I'm on",
|
||||||
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pluginData.guild.roles.has(pair[1])) {
|
if (!pluginData.guild.roles.has(pair[1])) {
|
||||||
|
|
|
@ -1255,6 +1255,10 @@ export async function renderRecursively(value, fn: RecursiveRenderFn) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isValidEmoji(emoji: string): boolean {
|
||||||
|
return isUnicodeEmoji(emoji) || isSnowflake(emoji);
|
||||||
|
}
|
||||||
|
|
||||||
export function canUseEmoji(client: Client, emoji: string): boolean {
|
export function canUseEmoji(client: Client, emoji: string): boolean {
|
||||||
if (isUnicodeEmoji(emoji)) {
|
if (isUnicodeEmoji(emoji)) {
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Reference in a new issue