import { Command } from 'discord-akairo'; import { Message } from 'discord.js'; export default class KickMod extends Command { public constructor() { super('kick', { aliases: ['kick'], category: 'moderation', description: { content: 'Kick a specified user from the server.', usage: '[user] [reason(s)]', examples: [ '@fun#1337', '@fun#1337 too cool' ] }, ratelimit: 3, channel: 'guild', clientPermissions: ['KICK_MEMBERS'], userPermissions: ['KICK_MEMBERS'], args: [ { id: 'user', type: 'string', prompt: { start: 'Which user would you like to kick?', retry: 'That doesn\'t seem to be a user, please try again!' } }, { id: 'reason', type: 'string', prompt: { start: 'For what reason would you like to kick this user?', optional: true }, match: 'rest' } ] }); } public async exec(msg: Message, { user, reason }): Promise { if (msg.mentions.members.first()) user = msg.mentions.members.first().id; if (user === this.client.user.id) return msg.channel.send('You can\'t kick me!'); if (!reason) reason = 'No reason has been specified.'; if (user === msg.author.id) return msg.channel.send('You can\'t kick yourself!'); user = msg.guild.members.cache.get(user); await user.send(`You have been kick from **${msg.guild.name}** for the following reason(s): "**${reason}**".`) .catch(() => console.log('[ERROR] Could not send message to this user.')); // TODO: fix reason showing up as [Object object] return user.kick({ reason: `Kicked by: ${msg.author.username} for the following reason(s): ${reason}.`}) .then(() => msg.reply(`${user.user.username} was successfully kick with the following reason(s): "**${reason}**".`)) .catch(err => console.error(err)); } }