我正在创建一个 discord 机器人,它每天在特定时间向公会发送消息。我正在为预定消息使用 cron
,但不确定要为机器人编写什么代码以将消息发送到公会的“通用” channel ,如果他们没有“通用” channel ' channel ,发送到事件或消息最多的 channel 。
自从 defaultChannel
被删除后,我不确定我应该怎么做。此外,我不想使用 channel ID 将消息发送到特定 channel ,因为我想公开此机器人,以便许多不同的公会可以使用。
cron.schedule('00 45 12,20 * * *', () => {
//code to send a message to guild's 'default channel' or 'channel with most activity goes here'
}, {
scheduled: true,
timeZone: "America/Los_Angeles"}
);
它不一定必须发送到“默认” channel 或大多数消息的 channel 。这些只是我想出的选项。基本上,我希望消息只发送到每个人都可以看到的 1 个 channel 。任何帮助,将不胜感激。谢谢!
最佳答案
This guide should be able to help you.尽管要小心机器人可以发送的第一个 channel ,但这也可能是公告。
不过,我的建议是使用数据库中的配置。这应该允许人们设置发送消息的 channel 。
关于javascript - 如何让 bot 将消息发送到 'general' channel 或消息最多的 channel ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52940937/