showing results for - "discord js nickname command"
Maëlys
19 Jan 2020
1const Discord = require('discord.js')
2
3exports.run = async (client, message, args) => {
4    if (!message.member.hasPermission('MANAGE_NICKNAMES')) return message.reply(`You cannot use this command as you do not have the \`MANAGE_NICKNAMES\` permission`);
5    if (!message.guild.me.hasPermission('MANAGE_NICKNAMES')) return message.reply('I cant use this command');
6
7    const mentionedMember = message.mentions.members.first() || message.guild.members.cache.get(args[0]);
8    const nickName = args.slice(1).join(" ");
9    var redBlob = message.guild.emojis.cache.find(emoji => emoji.name === 'redblob')
10
11
12    if (!args[0]) return message.reply('You did not mention a user for me to change there nickname!');
13    if (!mentionedMember) return message.reply('Please mention a user for me to change there nickname \`>nickname @user nickname\`');
14    if (!nickName) return message.reply('Please mention a nickname for me to change this users nickname');
15    if (!mentionedMember.kickable) return message.reply('This User Has a senior rank then me i cant change his nickname')
16
17    await mentionedMember.setNickname(nickName).catch(err => console.log(err)) && await message.reply(`${redBlob} Successfuly Changed ${mentionedMember} Nickname to ${nickName}`);
18  
19}
20