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

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

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

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

【问题讨论】:

    标签: javascript discord discord.js


    【解决方案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}`)
    

    【讨论】:

      猜你喜欢
      • 2021-04-26
      • 2021-08-14
      • 2018-03-20
      • 2020-12-28
      • 2020-09-06
      • 2019-07-10
      • 2019-12-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多