javascript - 如何通过 discord.js 发布到新的 NewsChannel
问题描述
我想让我的机器人能够发布到新的 ANNOUNCEMENTS_CHANNEL 功能 Discord.com 最近在整个平台上全球推出,但是 discord.js 文档在此功能上非常简约,但他们说NewsChannel extends TextChannel
。
我知道这确实有一个.send()
但不确定如何确认它NewsChannel
是一个在创建社区公会时激活的活动公告频道。
我会喜欢一些关于如何进行的提示和建议。
解决方案
如果要确保频道是公告频道,请检查频道“新闻”的类型。从此,您可以轻松地将消息发送到该频道,就像您通常使用普通文本频道所做的那样。
let channel = message.mentions.channels.firts()
// ^^ An option if you are getting the channel from a mention in the message
if (channel.type !== "news") return
channel.send("your message")
推荐阅读
- angular - 角度 4:错误类型错误:无法在控制台中读取未定义的属性“订阅”
- javascript - React - 当 Axios 在单独的组件中调用时,setState 不会重新渲染页面
- .net-core - 处理实现通用接口的总线事件时避免动态调用
- android - 如何在底部应用栏的菜单中设置项目的位置?
- python - Python:拆分数字并将它们分解为 2
- angular - Angular 9.0.4:使用 $localize:无法读取未定义的属性“loadChildren”中的错误
- node.js - 如何解决此终端问题
- firebase - 如何仅获取具有特定子文档 ID 的 firebase 文档或是否有其他方法?
- jquery - 需要帮助使用 Jquery Autocomplete 将字符串传递给 Ajax 帖子
- unit-testing - Vue.js 单元测试子发出调用父函数