无法读取未定义的不和谐的属性"查找".js



我正在尝试制造不和谐.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我在其他人的问题中找不到答案

msg.guilds

不存在。

你是说msg.guild吗?如果你想从该公会获得一个频道,你需要使用msg.guild.channels

根据您使用的版本:

11版:

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

12版:

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

使用它 (v12(

let channelID = "channeid";
client.channels.cache.get(channelID).send("Your Text")
// replace channelid to your channel id

简单,不是吗?

最新更新