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' ] }); } 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.') } } } };