2017-09-24 134 views
0

我有一个问题,我的discord.js机器人,我有一个轮询命令,但我希望它看到多少反应后,它有一定的时间用户要求,然后说(有更多的人喜欢X比喜欢Y的人更喜欢)。Discord.js结果轮询命令,需要一些工作

discord.js:

const Discord = require('discord.js') 

exports.run = async (bot, message, args) => { 
    if (!args) return message.reply("You must have something to vote for!") 
    if (!message.content.includes("?")) return message.reply("Include a ? in your vote!") 
    message.channel.send(`:ballot_box: ${message.author.username} started a vote! React to my next message to vote on it. :ballot_box: `); 
    const pollTopic = await message.channel.send(`${args}`); 
    pollTopic.react(`✅`); 
    pollTopic.react(`⛔`); 
}; 
+0

你遇到什么问题?什么没有用?请帮助我们帮助你:) –

+0

对不起,xD,我没有任何具体的答案,即时通讯只是基本上问了一个问题:“你怎么知道有多少反应比⛔有多少,反之亦然 – ThatMajesticGuy

回答

0

if (!args) return message.reply("You must have something to vote for!") if (!message.content.includes("?")) return message.reply("Include a ? in your vote!") message.channel.send(`:ballot_box: ${message.author.username} started a vote! React to my next message to vote on it. :ballot_box: `); const pollTopic = await message.channel.send(message.content.slice(2)); await pollTopic.react(`✅`); await pollTopic.react(`⛔`); // Create a reaction collector const filter = (reaction) => reaction.emoji.name === '✅'; const collector = pollTopic.createReactionCollector(filter, { time: 15000 }); collector.on('collect', r => console.log(`Collected ${r.emoji.name}`)); collector.on('end', collected => console.log(`Collected ${collected.size} items`));

我想这对我自己的机器人和它的所作所为是>首先,我使用的前缀只是人工智能这就是为什么我刚刚发来的message.content但切片2.我在Discord.js documentation的帮助下制作了反应收集器。 15秒钟后,将console.log与表情符✅作出反应的人数。只要看看我的代码,就可以根据您的偏好进行调整。如果你不明白,或者你想让我进一步解释,或者“我做错了什么”,然后回复给我。

相关问题