summaryrefslogtreecommitdiff
path: root/src/commands/moderation/addrole.ts
blob: 93645a2365119f09b7e8ae733e524a0265d809d9 (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
55
56
57
58
59
60
import { Command, CommandoMessage } from 'discord.js-commando';

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