[英]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.