summaryrefslogtreecommitdiff
path: root/src/commands/moderation/ban.ts
blob: 6bf6168588770d4afedd004e61d8eb0922796dac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { Command, CommandoMessage, CommandoClient } from 'discord.js-commando';
//@ts-ignore this has no types
import emoji from 'emoji-random'

module.exports = class BanModeration extends Command {
    constructor(client: CommandoClient) {
        super(client, {
            name: 'ban',
            aliases: ['banuser', 'ban-user'],
            group: 'moderation',
            memberName: 'ban',
            description: 'Ban someone.',
            userPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY', 'BAN_MEMBERS'],
            clientPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY', 'BAN_MEMBERS'],
            examples: [
                'uwu!ban @sin#1337',
                'uwu!banuser @sin#1337',
                'uwu!ban-user @sin#1337'
            ],
            throttling: {
                usages: 5,
                duration: 30
            },
            guildOnly: true
        });
    }
    //@ts-ignore this is not promsise based
    run(msg: CommandoMessage) {
        let userID = msg.mentions.members?.first()
        if (!userID?.id) {
            return msg.reply('No member was mentioned. ' + emoji.random())
        } else if (userID?.id == msg.author.id) {
            return msg.reply('You cannot ban yourself.' + emoji.random())
        } else if (userID?.id == this.client.user?.id) {
            return msg.reply('Not funny. ' + emoji.random())
        } else if (!msg.guild.member(userID.id)) {
            return msg.reply('Member does not exist in server.')
        } else {
            msg.guild.members.ban(userID.id)
            return msg.say(`**${userID}** has been banned!`).then(m => {
                //@ts-ignore yes this exists
                m.react('🇫');
            })
        }
    }
};