discord.js - DiscordJs 做出反应炸弹评论
问题描述
我想针对用反应轰炸评论的想法编写一个有趣的小代码。
我知道我需要什么,但我不知道如何获得它,我真的在互联网上搜索过,我似乎没有找到必要的功能。
我可能需要:评论 ID 和频道 ID,因此命令应该是:(前缀)命令(带有频道 ID 的 args0)(带有评论 ID 的 args1),这样它就可以对我想要的确切评论做出反应。
应该可以使用 if 函数来做到这一点
if (find(channel) and find(comment)){
message.react('EMOJI')
}else {return message.reply('need to specify channelID and commentID')} ```
Thanks
解决方案
您对问题的洞察力是绝对正确的,您可以这样实现:
let prefix = "!";
client.on("message", async (message) => {
if(message.author.bot) return
const args = message.content.slice(prefix.length).trim().split(' ')
if(message.content.toLowerCase() == "!bomb"){
if(!args[0]) return message.channel.send("Provide a channel ID")
if(!args[1]) return message.channel.send("Provide a message ID")
message.guild.channels.cache.get(`${args[0]}`).messages.fetch(`${args[1]}`).then(m => { m.react(""); });
message.channel.send("reacted");
}
})
推荐阅读
- mysql - 无法在 MySQL 存储过程中正确评估条件
- django - 表单提交后,Django Get Auth User pk 保存在模型中
- javafx - javafx中的initialize()是什么意思?
- google-apps-script - 具有非唯一键的 Google 表格中的 LEFT JOIN
- htmlunit - 通过 HtmlUnit 使用 ECharts 访问 HTML
- python - Django:带有PK问题的DetailView URL
- favicon - 生活网站图标 - 他们是如何做到的
- java - 如何使用 JPA 注释双 varchar 主键?
- c - 我无法将 argc 和 argv 从命令行获取到函数调用中
- php - 无法使用 httpClient 将字符串上传到我的 SSL 服务器