Discord.js机器人在用户之后对自己的消息做出反应!命令


client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
const { commandName } = interaction;
const gift = ["Gift 1", "Nothing", "Gift 3", "Nothing", "Gift 5", "Nothing", "Gift 7", "Nothing"]
const random = Math.floor(Math.random() * gift.length);

if (commandName === 'gift' && gift[random] === 'Nothing') {
interaction.reply("No Luck today!");
} else if (commandName === 'calendar' && gift[random] != 'Nothing') {
interaction.reply(`Congrats ${interaction.user.username} you won ${gift[random]} !`);
} 

});

我想让机器人对自己的答案做出反应:"今天运气不好!"或有人键入后的Congrats ${interaction.user.username} you won ${gift[random]} !!礼物,但交互没有反作用或反作用

你知道我该怎么做吗?

CommandInteraction#reply返回Message的一个实例。你可以在那里使用.react

interaction.reply("No Luck today!").then(m => m.react("emoji"))

对于另一条消息:

interaction.reply(`Congrats ${interaction.user.username} you won ${gift[random]} !`).then(m => m.react("emoji"))

相关内容

  • 没有找到相关文章

最新更新