【发布时间】:2020-08-28 14:16:37
【问题描述】:
错误: TypeError:无法读取 null 的属性“id” 在 Object.execute (/Users/Desktop/MSBTM/commands/ban.js:18:32) 在客户端。 (/Users/Desktop/MSBTM/bot.js:56:36)
这是我的代码:
const client = new Discord.Client();
module.exports = {
name: 'ban',
description: "ban peoples ;D",
execute(message, args) {
if (!message.member.hasPermission("BAN_MEMBERS") ||
!message.member.hasPermission("ADMINISTRATOR")) return message.channel.send("You don't have
a permissions to do this, maybe later ;)");
const user = message.mentions.users.first();
const member = message.guild.member(user);
const reason = args.slice(1).join(" ");
if (!user) return message.channel.send("Please mention the user to make this action");
if (user.id === message.author.id) return message.channel.send("You can't ban yourself, I tried :(");
if (user.id === client.user.id) return message.channel.send("You can't ban me, I tried :(");
if (!reason) reason = "No reason provided, please provide an reason to make this active";
member.ban(reason).then(() => {
message.channel.send(`Successfully banned **${user.tag}**`);
}).catch(err => {
message.reply("I was unable to ban the member :(");
})
}
}
有人可以帮我吗?
【问题讨论】:
标签: javascript visual-studio discord.js