summaryrefslogtreecommitdiff
path: root/src/commands/moderation/nickname.ts
blob: 910f7cadb69d2a53445d30cbcf4aeb9155d7a0f4 (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
import { Command, CommandoMessage, CommandoClient } from 'discord.js-commando';
//@ts-ignore this has no types
import emoji from 'emoji-random'

module.exports = class NicknameModeration extends Command {
    constructor(client: CommandoClient) {
        super(client, {
            name: 'nickname',
            aliases: ['nick'],
            group: 'moderation',
            memberName: 'nickname',
            description: 'Change someones nickname',
            userPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY', 'CHANGE_NICKNAME', 'MANAGE_NICKNAMES'],
            clientPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY', 'CHANGE_NICKNAME', 'MANAGE_NICKNAMES'],
            examples: [
                'uwu!nickname @sin#1337 loser',
                'uwu!nick @sin#1337 loser'
            ],
            throttling: {
                usages: 5,
                duration: 30
            },
            guildOnly: true,
            args: [
                {
                    key: 'user',
                    prompt: 'Which users nickname would you like to change?',
                    type: 'string'
                },
                {
                    key: 'nick',
                    prompt: 'What would you like to change their nickname to?',
                    type: 'string'
                }
            ]
        });
    }
    //@ts-ignore this aint async
    run(msg: CommandoMessage, { nick, user }: any) {
        msg.delete()
        if (msg.mentions.users) {
            user = msg.mentions.users.first()?.id
            if (nick) {
                msg.guild.members.cache.get(user)?.setNickname(nick)
                return msg.reply(`<@${user}>'s nickname has been changed to **${nick}**! ${emoji.random()}`).then(m => m.delete({ timeout: 3000 }))
            } else {
                return msg.reply(`No nickname was provided! ${emoji.random()}`)
            }
        } else {
            return msg.reply(`No valid member was mentioned! ${emoji.random()}`)
        }
    }
};