summaryrefslogtreecommitdiff
path: root/src/commands/moderation/removerole.ts
blob: a4edc928979f2aaf4a44ff3db2ad9d626d164920 (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
47
48
49
50
51
52
53
54
import { Command, CommandoMessage } from 'discord.js-commando';

module.exports = class RemoveRoleModeration extends Command {
    constructor(client) {
        super(client, {
            name: 'removerole',
            aliases: ['roleremove'],
            group: 'moderation',
            memberName: 'removerole',
            description: 'Removes a role to a specific user.',
            args: [
                {
                    key: 'userID',
                    prompt: 'Who would you like to remove the role from? (@someone or myself)',
                    type: 'string'
                },
                {
                    key: 'roleID',
                    prompt: 'What role would you like to remove?',
                    type: 'string'
                }
            ],
            userPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY', 'BAN_MEMBERS'],
            clientPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY', 'BAN_MEMBERS'],
            examples: [
                'uwu!removerole @CoolRole',
                'uwu!removerole @sin#1337 @CoolRole',
                'uwu!roleremove @sin#1337',
                'uwu!roleremove @sin#1337 @CoolerRole'
            ]
        });
    }
    run(msg: CommandoMessage, { userID, roleID }) {
        let role = msg.guild.roles.cache.find(r => r.id === roleID);
        let member = msg.mentions.members?.first();
        if (!userID) {
            if (role) {
                console.log(role)
                member?.roles.remove(role)
                msg.reply(`The role **${role}** has been remove from **${member}**.`)
            } else {
                console.log(role)
                msg.reply('Role is either non-existant or you might\'ve mispelled it.')
            }
        } else if (!userID) {
            if (roleID) {
                member?.roles.remove(roleID)
            } else {
                console.log(roleID)
                msg.reply('Role is either non-existant or you might\'ve mispelled it.')
            }
        }
    }
};