TypeError:无法读取未定义的属性(读取'成员')Discord JS
在我的机器人中,我不断遇到一个错误,因为它看不到参与者
const client = new Discord.Client({
intents: new Discord.Intents(32767)
})
const guild = client.guilds.cache.get('909512069999628349');
client.on('ready', () =>
{
guild.members.fetch()
.then(console.log)
.catch(console.error);
});
In my bot, I constantly get an error that it does not see participants
const client = new Discord.Client({
intents: new Discord.Intents(32767)
})
const guild = client.guilds.cache.get('909512069999628349');
client.on('ready', () =>
{
guild.members.fetch()
.then(console.log)
.catch(console.error);
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在试图获取行会之前,您的机器人没有登录不和谐。很简单。只需将
const guild
移入就绪事件中,或使用与此类似的黑客:Your bot is not being logged into Discord before the guild is attempted to be fetched. It's simple. Just move the
const guild
inside the Ready event, or use a hack similar to this:尝试使用
成员?.fetch()
,您的对象可能不确定Try using
members?.fetch()
, probably your object might be undefined so do this instead