如何使用不和谐机器人从不和谐频道随机发布文本?

Posted

技术标签:

【中文标题】如何使用不和谐机器人从不和谐频道随机发布文本?【英文标题】:How to randomly post texts from a discord channel with a discord bot? 【发布时间】:2020-08-25 13:29:58 【问题描述】:

我想制作一个不和谐的机器人,从我们互相转述的不和谐频道中挑选一条随机消息

“某事某事。” -某人,日期。

并将其发布到任何频道。由于我们已经对这些消息进行了这样的格式化,因此机器人只需要随机选择一个并发布它而不做任何更改。

【问题讨论】:

【参考方案1】:

您可以获取channelmessages,然后选择random() 1 并使用它的数据发送报价。

const channel = client.channels.cache.get(CHANNEL_ID) // you can use `message.channel` instead of this variable if you want to get the message from the channel you send the command
const randomMsg = channel.messages.cache.random(1)
message.channel.send(`"$randomMsg.content" -$message.author, $message.createdAt`)

【讨论】:

以上是关于如何使用不和谐机器人从不和谐频道随机发布文本?的主要内容,如果未能解决你的问题,请参考以下文章