import { Message , Guild , Util } from 'discord.js' ; import { commandInterface } from '../../commands' ; import { permLevels , getPermLevel } from '../../utils/permissions' ; import { Bot } from '../..' ; import { sendError } from '../../utils/messages' ; import { permToString , durationToString , stringToMember } from '../../utils/parsers' ; import { durations } from '../../utils/time' ; var command = { name : 'kick' , path : '' , dm : false , permLevel : permLevels . mod , togglable : false , cooldownLocal : durations . second , help : { shortDescription : 'Kick members' , longDescription : 'Kick a member from this server' , usages : [ '{command} [member]' , '{command} [member] [reason]' ] , examples : [ '{command} @jeff#1234' , '{command} @jeff#1234 for not being a good boi' ] } , run : async ( message , args , permLevel , dm , requestTime ) => { try { if ( args . length == 0 ) { message . channel . send ( await Bot . commands . getHelpEmbed ( command , message . guild ) ) ; Bot . mStats . logMessageSend ( ) ; return false ; } let argIndex = 0 ; let argsArray = args . split ( ' ' ) . filter ( x => x . length != 0 ) ; let member = await stringToMember ( message . guild , argsArray [ argIndex ] , false , false , false ) ; if ( ! member ) { message . channel . send ( 'Couldn\'t find specified member' ) ; Bot . mStats . logMessageSend ( ) ; return false ; } if ( member . user . id == message . author . id ) { message . channel . send ( 'You can\'t kick yourself' ) ; Bot . mStats . logMessageSend ( ) ; return false ; } if ( member . user . id == Bot . client . user . id ) { message . channel . send ( 'You can\'t kick me :smiling_imp:' ) ; Bot . mStats . logMessageSend ( ) ; return false ; } if ( await getPermLevel ( member ) >= permLevels . mod ) { message . channel . send ( 'You can\'t kick that member' ) ; Bot . mStats . logMessageSend ( ) ; return false ; } if ( ! await message . guild . me . hasPermission ( "KICK_MEMBERS" ) ) { message . channel . send ( "I don\'t have the permissions to do that" ) ; Bot . mStats . logMessageSend ( ) ; return false ; } let reason = args . slice ( args . indexOf ( argsArray [ 0 ] ) + argsArray [ 0 ] . length ) . trim ( ) ; await Bot . caseLogger . logKick ( message . guild , member , message . member , reason ) ; await member . send ( `You were kicked from **${ message . guild . name }** ${ reason ? 'for:\n' + reason : '' }` ) ; Bot . mStats . logMessageSend ( ) ; member . kick ( reason ) ; Bot . mStats . logResponseTime ( command . name , requestTime ) ; message . channel . send ( `:white_check_mark: **${ member . user . tag } has been kicked${ reason ? ', ' + Util . escapeMarkdown ( reason ) : '' }**` ) ; Bot . mStats . logCommandUsage ( command . name ) ; Bot . mStats . logMessageSend ( ) ; return true ; } catch ( e ) { sendError ( message . channel , e ) ; Bot . mStats . logError ( e , command . name ) ; return false ; } } } ; export default command ;