diff options
| author | 8cy <[email protected]> | 2020-07-23 23:24:17 -0700 |
|---|---|---|
| committer | 8cy <[email protected]> | 2020-07-23 23:24:17 -0700 |
| commit | bb511abc03bb66848947e37a999502b813c77269 (patch) | |
| tree | 612c010fc8317e1cdf11471a18aad0270819d33e /server/src/commands/reaction/Remove.ts | |
| parent | fix: if clear amount equal or over 100, round down to 99 (diff) | |
| download | dep-core-bb511abc03bb66848947e37a999502b813c77269.tar.xz dep-core-bb511abc03bb66848947e37a999502b813c77269.zip | |
goodbye old uwufier :cry:
Diffstat (limited to 'server/src/commands/reaction/Remove.ts')
| -rw-r--r-- | server/src/commands/reaction/Remove.ts | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/server/src/commands/reaction/Remove.ts b/server/src/commands/reaction/Remove.ts new file mode 100644 index 0000000..0a58cdd --- /dev/null +++ b/server/src/commands/reaction/Remove.ts @@ -0,0 +1,61 @@ +import { Command } from 'discord-akairo'; +import { Message, TextChannel } from 'discord.js'; +import { Reaction } from '../../database/models/ReactionModel'; + +export default class RemoveReaction extends Command { + public constructor() { + super('reactionremove', { + aliases: ['reactionremove', 'reactionrm', 'reactiondelete', 'reactiondel'], + category: 'reactions', + description: { + content: 'Removes a reaction from a message via an discriminator.', + usage: '[discriminator]', + examples: [ + '[fV9k]' + ] + }, + ratelimit: 3, + userPermissions: ['MANAGE_ROLES'], + channel: 'guild', + args: [ + { + id: 'reaction', + type: (msg: Message, str: string): Reaction | null => { + const req = this.client.settings.cache.reactions.find(r => r.id === str && r.guildID === msg.guild!.id); + if (!req) return null; + return req; + }, + match: 'rest', + prompt: { + start: "Please provide the unique identifier for the reaction you'd like to delete.", + retry: + "Please provide a valid identifier for the reaction role you'd like to delete. You can also delete the whole message to delete reaction roles on it.", + }, + }, + ], + }); + } + + public async exec(msg: Message, { reaction }: { reaction: Reaction }): Promise<Message | Message[] | void> { + this.client.logger.info(reaction); + try { + const chan = this.client.channels.cache.get(reaction.channelID) as TextChannel; + if (!chan) throw new Error("That channel doesn't exist!"); + const message = await chan.messages.fetch(reaction.messageID); + if (!message) throw new Error("That message doesn't exist!"); + await message.reactions.cache.get(reaction.emoji)!.users.remove(this.client.user!.id); + } catch (err) { + this.client.logger.error(`[ERROR in REMOVE CMD]: ${err}.`); + } + + this.client.settings.set( + 'reaction', + { messageID: reaction.messageID }, + { + active: false, + }, + ); + + return msg.reply('successfully deleted that reaction role.'); + } +}
\ No newline at end of file |