mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-16 22:21:51 +00:00
ReactionRoles: show an error for invalid emojis
This commit is contained in:
parent
d125176907
commit
56b1ae8785
1 changed files with 17 additions and 5 deletions
|
@ -1,14 +1,15 @@
|
||||||
import { decorators as d, IPluginOptions, logger } from "knub";
|
import { decorators as d, IPluginOptions, logger } from "knub";
|
||||||
import { CustomEmoji, errorMessage, isSnowflake, noop, sleep, successMessage } from "../utils";
|
import { CustomEmoji, errorMessage, isSnowflake, noop, sleep } from "../utils";
|
||||||
import { GuildReactionRoles } from "../data/GuildReactionRoles";
|
import { GuildReactionRoles } from "../data/GuildReactionRoles";
|
||||||
import { Message, TextChannel } from "eris";
|
import { Message, TextChannel } from "eris";
|
||||||
import { ZeppelinPlugin } from "./ZeppelinPlugin";
|
import { ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||||
import { GuildSavedMessages } from "../data/GuildSavedMessages";
|
import { GuildSavedMessages } from "../data/GuildSavedMessages";
|
||||||
import { Queue } from "../Queue";
|
import { Queue } from "../Queue";
|
||||||
import { ReactionRole } from "../data/entities/ReactionRole";
|
import { ReactionRole } from "../data/entities/ReactionRole";
|
||||||
import Timeout = NodeJS.Timeout;
|
|
||||||
import DiscordRESTError from "eris/lib/errors/DiscordRESTError"; // tslint:disable-line
|
import DiscordRESTError from "eris/lib/errors/DiscordRESTError"; // tslint:disable-line
|
||||||
import * as t from "io-ts";
|
import * as t from "io-ts";
|
||||||
|
import { ERRORS, RecoverablePluginError } from "../RecoverablePluginError";
|
||||||
|
import Timeout = NodeJS.Timeout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Either of:
|
* Either of:
|
||||||
|
@ -335,9 +336,20 @@ export class ReactionRolesPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.canUseEmoji(pair[0])) {
|
try {
|
||||||
msg.channel.createMessage(errorMessage("I can only use regular emojis and custom emojis from servers I'm on"));
|
if (!this.canUseEmoji(pair[0])) {
|
||||||
return;
|
msg.channel.createMessage(
|
||||||
|
errorMessage("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) {
|
||||||
|
msg.channel.createMessage(errorMessage(`Invalid emoji: ${pair[0]}`));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.guild.roles.has(pair[1])) {
|
if (!this.guild.roles.has(pair[1])) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue