我一直在寻找此错误的解决方案,但直到现在我还没有找到任何解决方案,现在我已经放弃,因为我花了超过1天的时间才能找到解决方案,现在我在这里发布了我的问题,因此任何人都可以看到并评论为什么会显示错误?
问题: ReferenceError: member is not defined(8:16)
我的代码:
1: const discord = require("discord.js");
2: const config = require('../config.json');
3:
4: module.exports.run = async (bot, message, args) => {
5:
6: let target = message.guild.member(message.mentions.users.first());
7: let reason = args.slice(1).join(' ');
8: let logs = member.guild.channels.find(channel => channel.name === "⚠server_logs");
9:
10: // member.guild.channels.cache.find('⚠server_logs', config.logsChannel);
11:
12: if (!message.member.hasPermission('BAN_MEMBERS')) return message.reply('you don\'t have permissions to use this command!s');
13:
14: if (!target) return message.reply('please specify a member to ban!');
15: if (!reason) return message.reply('please specify a reason for this ban!');
16: if (!logs) return message.reply(`please create a channel called ${config.logsChannel} to log the bans!`);
17:
18: let embed = new discord.RichEmbed()
19: .setColor('RANDOM')
20: .setThumbnail(target.user.avatarURL)
21: .addField('Banned Member', `${target.user.username} with an ID: ${target.user,id}`)
22: .addField('Banned By', `${message.author.username} with an ID: ${message.author.id}`)
23: .addField('Banned Time', message.createdAt)
24: .addField('Banned At', message.channel)
25: .addField('Banned Reason', reason)
26: .addFooter('Banned user information', target.user.displayAvatarURL);
27:
28: message.channel.send(`${target.user.username} was banned by ${message.author} for ${reason}`);
29: target.ban(reason);
30: logs.send(embed);
31: };
32:
33: module.exports.help = {
34: name: 'ban'
35: };
答案 0 :(得分:0)
在代码中,行号。 8
6: let target = message.guild.member(message.mentions.users.first());
7: let reason = args.slice(1).join(' ');
8: let logs = member.guild.channels.find(channel => channel.name === "⚠server_logs");
您在使用member.guild.channels
时没有定义成员nad,因此没有引用错误。我相信应该是message.guild.member
。
这里是一篇博客,解释了参考错误:
https://airbrake.io/blog/nodejs-error-handling/referenceerror