2017-09-24 115 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與表情符✅作出反應的人數。只要看看我的代碼,就可以根據您的偏好進行調整。如果你不明白,或者你想讓我進一步解釋,或者「我做錯了什麼」,然後回覆給我。

相關問題