【发布时间】:2020-08-25 13:29:58
【问题描述】:
我想制作一个不和谐的机器人,从我们互相转述的不和谐频道中挑选一条随机消息
“某事某事。” -某人,日期。
并将其发布到任何频道。由于我们已经对这些消息进行了这样的格式化,因此机器人只需要随机选择一个并发布它而不做任何更改。
【问题讨论】:
标签: javascript discord discord.js
我想制作一个不和谐的机器人,从我们互相转述的不和谐频道中挑选一条随机消息
“某事某事。” -某人,日期。
并将其发布到任何频道。由于我们已经对这些消息进行了这样的格式化,因此机器人只需要随机选择一个并发布它而不做任何更改。
【问题讨论】:
标签: javascript discord discord.js
您可以获取channel 的messages,然后选择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}`)
【讨论】: