简体   繁体   English

如何修复 Discord 机器人的踢腿命令?

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

When I type "exp kick @user being toxic", it doesn't respond with anything: it simply ignores my command.当我输入“exp kick @user betoxic”时,它没有任何反应:它只是忽略我的命令。 Here is my code:这是我的代码:

client.on("message", message => {
    var command = message.content.toLowerCase().split("")[0]
    if(command == prefix + "kick"){
        if(message.guild.member(message.author).hasPermission("KICK_MEMBERS"))
        return message.channel.send("Please Check Your Permissions")
        if(!message.guild.memeber(client.user).hasPermission("KICK_MEMBERS"))
        return message.channel.send("Please Check My Permissions")
        const user = message.mentions.user.first()
        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")
        message.guild.member(user).kick({reason: reason})
        return message.channel.send("Kicked the filthy member `@"+user.tag+"` ")

    }
})

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 + ">");
  }
})

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何为我的机器人制定禁令、踢出和清除命令? - How do I make a ban, kick and clear command for my bot? 我的 discord 机器人不响应踢命令 - My discord bot doesn't respond for kick command 如何在我的 Discord 机器人中修复这些类型错误? - How can I fix these TypeErrors in my Discord bot? 我对我的 discord bot Kick 系统有疑问 - I have a question with my discord bot Kick system 我试图制作一个 discord 机器人,主要是为了好玩,但我似乎无法让我的 kick 命令中使用的 if else 语句正常工作 - Im trying to make a discord bot mostly just for fun but i cant seem to get the if else statements used in my kick command to work properly 我怎样才能实现!leaveguild<guildid> 命令(离开指定的公会)进入我的 Discord (discord.js) 机器人?</guildid> - How can I implement a !leaveguild <guildID> command (that leaves the specified guild) into my Discord (discord.js) bot? 当我启动我的机器人 discord 时出现错误,我找不到解决方法 - when i launch my bot discord i have an error and i can't find how to fix it 我如何为我尝试创建的 Discord 机器人修复此错误? - How can I fix this error for my Discord bot I'm trying to make? 我的 discord 机器人出现错误,请告知如何修复 - i an getting an error in my discord bot, please tell how fix 最近我建立了 discord bot,主要问题是,我不知道如何设置权限,所以我服务器的每个成员都可以踢和禁止其他人 - recently i build discord bot, the main problem is, i dont know how to set the permission, so every member of my server can kick and ban others
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM