当我键入“ exp kick @user is toxic”时,它没有任何响应:它只是忽略了我的命令。这是我的代码:
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+"` ")
}
})
答案 0 :(得分:2)
老实说,您做了很多错别字...我已修复它,它应该可以工作,下面是您弄乱的部分,下面是我所做的修复。我必须使它整洁,因为我几乎看不懂它。
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 + ">");
}
})