简体   繁体   English

Node.js Discord.js 从 ID v11 向通道发送消息

[英]Node.js Discord.js Send message to channel from ID v11

In Discord.js V11 how can I send a message to a specific channel from the ID?在 Discord.js V11 中,如何从 ID 向特定频道发送消息? (all I can find is on V12, I need V11) Thanks! (我只能找到 V12,我需要 V11)谢谢!

From the documentation for v11, you can simply use client.channels.get(id) (without "fetch") to get the channel:从 v11 的文档中,您可以简单地使用client.channels.get(id) (不带“fetch”)来获取频道:

All of the Channels that the client is currently handling, mapped by their IDs - as long as sharding isn't being used, this will be every channel in every guild, and all DM channels客户端当前正在处理的所有频道,由他们的 ID 映射 - 只要不使用分片,这将是每个公会中的每个频道,以及所有 DM 频道

You could then send a message to the channel:然后,您可以向频道发送消息:

const channel = client.channels.get('yourID');
channel.send('Hello!');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM