discord.js - Unhandled promise rejection: ReferenceError: member is not defined
问题描述
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.`);
}
}
解决方案
将此行更改if (!member.bannable) return message.channel.send('This user can\'t be muted.');
为if (!user.bannable) return message.channel.send('This user can\'t be muted.');
推荐阅读
- flutter - Flutter 创建带有文本和加载器的启动画面
- php - 使用边界半径的圆角动态生成 li
- c# - 找不到类型或命名空间名称 Unity
- ssl - 使用 github 页面的安全 https 重定向和 letencrypt 不起作用
- python - 循环遍历多列以在数字列中查找字符串?
- key - 公钥不存在或不可读
- embedded - Disable interrupt to let freeRTOS run on stm32
- google-cloud-data-fusion - 条件组件
- javascript - 为项目外的文件创建路径别名
- python - /usr/bin/python:错误的解释器:安装 python 2.7 后没有这样的文件或目录