ReferenceError:未定义成员
Posted
技术标签:
【中文标题】ReferenceError:未定义成员【英文标题】:ReferenceError: member is not defined 【发布时间】:2020-09-18 13:52:38 【问题描述】:我一直在寻找这个错误的解决方案,但直到现在我还没有找到任何解决方案,现在我已经放弃了,因为我花了超过 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: ;
【问题讨论】:
【参考方案1】:在代码中,行号。 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
【讨论】:
Np 我会试试 :)) 现在出现了这个问题:TypeError: Cannot read property 'find' of undefined
以上是关于ReferenceError:未定义成员的主要内容,如果未能解决你的问题,请参考以下文章
app.js:81010 [Vue 警告]:挂载钩子错误:“ReferenceError: $store 未定义”