无法读取未定义Discord.js的属性“查找”

时间:2020-06-14 19:07:06

标签: bots discord discord.js

我正试图让discord.js机器人从一个通道删除经过审查的消息,并将其记录在管理通道中,这是我的代码:

 msg.channel.send(exampleEmbed1);
 msg.guilds.find("721079782833520651").send("Test")
It says this error:

 TypeError: Cannot read property 'find' of undefined
 at Client.<anonymous> (/Users/DShirriff/rebelbot/rebel.js:35:16)
 at Client.emit (events.js:323:22)
 at MessageCreateAction.handle (/Users/DShirriff/rebelbot/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
 at Object.module.exports [as MESSAGE_CREATE] (/Users/DShirriff/rebelbot/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32) etc.

请某人帮助:)我是discord.js的新手,我在其他人的问题中找不到答案

1 个答案:

答案 0 :(得分:0)

msg.guilds不存在。

您是说msg.guild吗?如果您想从该行会获得频道,则需要使用msg.guild.channels

取决于您使用的版本:

v11:

const channel = msg.guild.channels.get("channel_id");

v12:

const channel = msg.guild.channels.cache.get("channel_id");