[Solved] How can I fix my kick command for my Discord bot?


You made a bunch of typos, honestly… I fixed it and it should be working, below are the parts which you messed up in, and the one below that is the fix I made. I had to make it neater because I can barely read it.


client.on("message", message => {
    var command = message.content.toLowerCase().split("")[0]
    if(command == prefix + "kick"){
        if(message.guild.member(message.author).hasPermission("KICK_MEMBERS"))
        // ^ You forgot to add `!`
        return message.channel.send("Please Check Your Permissions")
        // Putting return like this can sometimes end up breaking your code. Put it without space.
        if(!message.guild.memeber(client.user).hasPermission("KICK_MEMBERS"))
        //                ^^^^^^^ The correct spelling is `member`
        return message.channel.send("Please Check My Permissions")
        const user = message.mentions.user.first()
        //                            ^^^^ It's `users` not `user`
        if(!user) return message.channel.send("I can't find this user!")
        const reason = message.content.split(" ").slice(2).join(" ")
        if(!reason) return message.channel.send("Please state the reason for kick!")
        if(message.guild.memeber(user).kickable) return message.channel.send("This user seems to have persmissions which got in the way")
        // ^ Kickable returns true if the bot can kick it, while false if it can't, add `!`
        //               ^^^^^^^ Again with the wrong spelling
        message.guild.member(user).kick({reason: reason})
        return message.channel.send("Kicked the filthy member `@"+user.tag+"` ")
        //                                                    ^^^^^^^^^^^^^^^ Use "<@" + user.id + ">" instead to mention.
    }
})

client.on("message", message => {
  var command = message.toLowerCase().split(" ")[0];
// Add one space to split to split string to individual array variables
  if(command == prefix + "kick") {
    const user = message.mentions.users.first();
    const reason = message.content.split(" ").slice(2).join(" ");
    if(!message.guild.member(message.author).hasPermission("KICK_MEMBERS")) return message.channel.send("Please Check Your Permissions")
    if(!message.guild.member(client.user).hasPermission("KICK_MEMBERS")) return message.channel.send("Please Check My Permissions");
    if (!user) return message.channel.send("I can't find this user!");
    if (!reason) return message.channel.send("Please state the reason for kick!");
    if (!message.guild.member(user).kickable) return message.channel.send("This user seems to have permissions which got in the way");
    message.guild.member(user).kick({reason: reason});
    return message.channel.send("Kicked the filthy member <@" + user.id + ">");
  }
})

7

solved How can I fix my kick command for my Discord bot?