所以我一直在尝试为我的不和谐机器人发出静音命令,每次我使用该命令时,机器人都会崩溃并离线(我使用 replit.com 来托管我的机器人)
这是代码;
if(message.content.startsWith("!mute")) {
if(!member.member.hasPermission("KICK_MEMBERS")) return message.channel.send("You don't have the permissions to execute this command!")
let role = message.guild.roles.cache.find(role => role.name === "muted")
let member = message.mentions.members.first()
let reason = message.content.split(" ").slice(2).join(" ")
if(!reason) reason = "No reason has been specified!"
if(!role) return message.channel.send("This server doesn't have a muted role!")
if(!member) return message.channel.send("You didn't mention a member!")
if(member.roles.cache.has(role.id)) return message.channel.send("That user is already muted!")
member.roles.add(role)
.then(() => {
message.channel.send(`Sucessfully muted ${member} with the reasoning ${reason}`)
})
.catch(() => {
message.channel.send("Oops something went wrong with the command! Try again in a few seconds")
})
}
谁能告诉我有什么问题吗?