久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Discord.js:如何發(fā)送消息并從中收集反應(yīng)

Discord.js: How to send a message and collect reactions from it(Discord.js:如何發(fā)送消息并從中收集反應(yīng))
本文介紹了Discord.js:如何發(fā)送消息并從中收集反應(yīng)的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我希望 discord.js 機(jī)器人在執(zhí)行命令時(shí)發(fā)送消息,對其做出反應(yīng),然后捕獲用戶的所有反應(yīng)以執(zhí)行某些操作,例如響應(yīng)他們.反應(yīng)不應(yīng)有時(shí)間限制.我還應(yīng)該提到我正在使用命令處理程序,并且消息是從 index.js 以外的另一個(gè)文件發(fā)送的(甚至應(yīng)該在其中發(fā)生收集).

I want the discord.js bot to send a message when a command is executed, react on it and then catch all reactions from users to do certain stuff, like respond to them. No time limit should be applied to reactions. I should also mention that I'm using a command handler and the message is being sent from another file than index.js (in which the collect even should occur).

我嘗試做一個(gè)收集器,但無論我怎么做,收集器變量都沒有定義或不起作用.我知道它應(yīng)該是一個(gè)事實(shí)的收集器.

I tried doing a collector but no matter how I do it, the collector variable is not defined or not working. I know it should be a collector for a fact though.

為復(fù)選標(biāo)記表情符號制作過濾器:

Making a filter for the checkmark emoji:

  return reaction.emoji.name === `?` && user.id === call.message.author.id;
}

試圖捕捉命令塊本身之外的反應(yīng)(因?yàn)槿绻以趬K中這樣做,事件將不起作用:

Trying to catch reactions outside the command block itself (because if I do it IN the block the event won't work:

collector.on(`collect`, (reaction, reactionCollector) => {
    console.log(`Caught ${reaction.emoji.name}`);
});

我得到的錯(cuò)誤幾乎是意料之中的,但我想解決這個(gè)問題:

The errors I get are pretty much expected but I want to solve that:

collector.on(`collect`, (reaction, reactionCollector) => {
^

ReferenceError: collector is not defined

也許是一個(gè)全局變量或設(shè)置消息 id 然后獲取?幫幫我.

Maybe a global variable or setting the message id and then fetching? Help me.

推薦答案

為什么不在你的 command.js 中包含 Collector?

Why not include the Collector in your command.js?

 const time = 60000 //amount of time to collect for in milliseconds

 receivedMessage.channel.send("Hello World")
 .then(async function (message) {
      await message.react('?')
      const filter = (reaction, user) => {
           return //YOUR FILTER HERE;
      };

      const collector = message.createReactionCollector(filter, { time: time });

      collector.on('collect', (reaction, reactionCollector) => {
           //do stuff
      });
 });

這篇關(guān)于Discord.js:如何發(fā)送消息并從中收集反應(yīng)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Using discord.js to detect image and respond(使用 discord.js 檢測圖像并響應(yīng))
Check if user ID exists in Discord server(檢查 Discord 服務(wù)器中是否存在用戶 ID)
Guild Member Add does not work (discordjs)(公會(huì)成員添加不起作用(discordjs))
Creating my first bot using REPLIT but always error Discord.JS(使用 REPLIT 創(chuàng)建我的第一個(gè)機(jī)器人,但總是錯(cuò)誤 Discord.JS)
How do I code event/command handlers for my Discord.js bot?(如何為我的 Discord.js 機(jī)器人編寫事件/命令處理程序?)
How to find a User ID from a Username in Discord.js?(如何從 Discord.js 中的用戶名中查找用戶 ID?)
主站蜘蛛池模板: 成人在线影视 | 又黑又粗又长的欧美一区 | 国产欧美一区二区三区久久人妖 | 免费黄色大片 | 欧美在线免费 | www.v888av.com| 一级全黄少妇性色生活免费看 | 久久久tv | 欧美性生活一区二区三区 | 91视频在线 | 欧美黑人国产人伦爽爽爽 | 日韩免费高清视频 | 91免费在线 | 欧美日韩一区二区在线 | 国产精品视频一二三区 | 男人天堂网址 | 久久婷婷麻豆国产91天堂 | 国产欧美精品 | 欧美日韩不卡合集视频 | 亚洲小视频在线观看 | 日韩av手机在线观看 | 成人网址在线观看 | 国产欧美日韩 | 久久免费精品 | 亚洲一区二区三区久久久 | 亚洲视频免费在线观看 | 一区二区三区av | 天天久久| 在线观看亚洲一区二区 | 欧美视频在线播放 | 天天拍天天插 | 免费观看日韩精品 | 一区二区视频 | 三级免费 | 麻豆久久久9性大片 | 国产99免费 | 日韩av免费在线电影 | 国产精品免费播放 | 国产一区二区在线免费观看 | 成人午夜免费福利视频 | 日韩高清av |