My code has an error: Unhandled promise rejection: ReferenceError: member is not defined. My code used to work, but now it just doesn't work. I haven't made any changes with the code. Here's my code:
module.exports = {
name: "mute",
description: "Mute a member from your server",
async run(client, message, args) {
if (!message.member.hasPermission("MANAGE_ROLES")) return message.channel.send('You can't use this command ( ?° ?? ?°).');
let user = message.mentions.members.first() || message.guild.members.cache.get(args[0]);
if (!user) message.channel.send("Please tag a user to mute.");
if (user.id === message.author.id) return message.channel.send('lmao you can't mute yourself');
if (!member.bannable) return message.channel.send('This user can't be muted.');
let role = message.guild.roles.cache.find(x => x.name === "Muted");
if (!role) return message.channel.send("Something went wrong.");
let reason = args.slice(1).join(" ");
if (reason === null) reason = "Unspecified"
user.roles.add(role);
await message.channel.send(`${user} was muted. That was nice.`);
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…