You've already forked discord-bot
mirror of
https://github.com/t2linux/discord-bot.git
synced 2026-04-30 13:49:21 -07:00
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
import { Channel, Emoji, GuildMember, Message } from 'discord.js';
|
|
import { config, data } from '..';
|
|
import { Argument } from '../argument';
|
|
import { ChannelArgument } from '../arguments/channelArgument';
|
|
import { EmojiArgument } from '../arguments/emojiArgument';
|
|
import { Command } from '../command';
|
|
|
|
export class RemoveRoleCommand extends Command {
|
|
|
|
public name(): string {
|
|
return 'removeRole';
|
|
}
|
|
|
|
public description(): string {
|
|
return 'Removes an emoji as an reaction emoji from a specified channel';
|
|
}
|
|
|
|
public arguments(): Array<Argument> {
|
|
return [
|
|
{ name: 'channel', type: 'Channel', description: 'The channel in which the reaction emoji should be removed' },
|
|
{ name: 'emoji', type: 'CustomEmoji | UnicodeEmoji', description: 'The emoji of the reaction emoji to be removed' }
|
|
];
|
|
}
|
|
|
|
public async permitted(member: GuildMember): Promise<boolean> {
|
|
return config.discord.admin.includes(member.id);
|
|
}
|
|
|
|
public async handle(message: Message, args: Array<string>): Promise<void> {
|
|
const [ channelArgument, emojiArgument ] = args;
|
|
|
|
const channel: Channel = await ChannelArgument.parse(channelArgument);
|
|
const emoji: string | Emoji = await EmojiArgument.parse(message, emojiArgument);
|
|
|
|
const emojiId: string = typeof emoji === 'string' ? emoji : emoji.id;
|
|
|
|
data.removeEmoji(channel.id, emojiId);
|
|
|
|
message.react('👌');
|
|
}
|
|
} |