首页 > 解决方案 > 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

标签: discord.js

解决方案


您对问题的洞察力是绝对正确的,您可以这样实现:

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");
}
})

推荐阅读