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

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

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

問題描述

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

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

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.

為復選標記表情符號制作過濾器:

Making a filter for the checkmark emoji:

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

試圖捕捉命令塊本身之外的反應(因為如果我在塊中這樣做,事件將不起作用:

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

我得到的錯誤幾乎是意料之中的,但我想解決這個問題:

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

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

ReferenceError: collector is not defined

也許是一個全局變量或設置消息 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ā)送消息并從中收集反應的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 檢測圖像并響應)
Check if user ID exists in Discord server(檢查 Discord 服務器中是否存在用戶 ID)
Guild Member Add does not work (discordjs)(公會成員添加不起作用(discordjs))
Creating my first bot using REPLIT but always error Discord.JS(使用 REPLIT 創(chuàng)建我的第一個機器人,但總是錯誤 Discord.JS)
How do I code event/command handlers for my Discord.js bot?(如何為我的 Discord.js 機器人編寫事件/命令處理程序?)
How to find a User ID from a Username in Discord.js?(如何從 Discord.js 中的用戶名中查找用戶 ID?)
主站蜘蛛池模板: 紧缚调教一区二区三区视频 | 免费精品一区 | 国产成人精品久久二区二区91 | 亚洲精品一区二区 | 综合五月 | 国产亚洲精品精品国产亚洲综合 | 国产不卡在线观看 | 日韩av高清 | 免费一级毛片 | 91久久久精品国产一区二区蜜臀 | 91精品国产91久久久久福利 | 婷婷色在线播放 | 亚洲综合首页 | 久久久久黑人 | 亚洲 欧美 日韩 精品 | 精品国产乱码久久久久久丨区2区 | 久久久久久久久久久成人 | 国产精品毛片一区二区三区 | 天天摸天天看 | 国产免国产免费 | 欧美精品91爱爱 | 免费精品 | 欧美a区 | 国产高清一二三区 | www久久国产 | 欧美一区二区三区大片 | 日韩欧美精品一区 | 国产精品久久久久一区二区三区 | 国产二区三区 | 丁香综合| 欧美日韩激情 | 亚洲成人一区二区 | 天天干精品 | 伊人精品在线 | 成人午夜免费网站 | 我要看免费一级毛片 | 黄网站涩免费蜜桃网站 | 先锋资源网站 | 久久99精品视频 | 欧洲性生活视频 | 久久亚洲国产精品日日av夜夜 |