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

如何使reactionCollector 對remove 事件起作用?

How can I make a reactionCollector on a remove event work?(如何使reactionCollector 對remove 事件起作用?)
本文介紹了如何使reactionCollector 對remove 事件起作用?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

所以,我正在開發(fā)一個不和諧的機器人.這里我開始一個reactionCollector.當(dāng)一個反應(yīng)被收集時,它會做一些事情,當(dāng)反應(yīng)被移除時,它應(yīng)該做其他事情.

So, I am working on a discord bot. Here I start a reactionCollector. When a reaction is collected, it does something, and when the reaction is removed, it should do something else.

await message.channel.send(embed)
  then(async function (message) {
    await message.react('?')

    const filter = (reaction, user) => {
      return reaction.emoji.name === '?' && user.id != 705462496646922311
    };
    collector = message.createReactionCollector(filter);

    collector.on('collect', async (reaction, user) => {
      // Do something.
    });

    collector.on('remove', (reaction, user) => {
      // Do something.
    });
  })
  .catch(function() {
    message.channel.send('Error while adding the reaction. Try again')
  });

永遠(yuǎn)不會調(diào)用 remove 事件.有誰知道為什么會這樣?我哪里做錯了?

The remove event never gets called. Does anyone know why this happen? Where did I do a mistake?

推薦答案

讓你的 ReactionCollector 觸發(fā) disposeremove 事件,您必須在 dispose/discord.js.org/#/docs/main/stable/typedef/CollectorOptions" rel="nofollow noreferrer">CollectorOptions 你的 ReactionCollector 就像這樣:

To make your ReactionCollector fire dispose and remove events you have to enable dispose in the CollectorOptions of your ReactionCollector just like that :

collector = message.createReactionCollector(filter, { dispose: true });

另外,在操作 ID 時要小心(Snowflakes),它們總是字符串類型.在您的代碼中,您嘗試查看 user.id 是否不等于一個數(shù)字(順便說一下,這個數(shù)字真的很大!)所以不要忘記用引號將 ID 括起來.

Also, be carefull when manipulating IDs (Snowflakes), they are always type of String. In your code you try to see if user.id is not equal to a number (really big number by the way!) so don't forget to surround IDs with quotes.

return reaction.emoji.name === '?' && user.id != "705462496646922311";

這篇關(guān)于如何使reactionCollector 對remove 事件起作用?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 頻道中的消息?)
how to make my bot mention the person who gave that bot command(如何讓我的機器人提及發(fā)出該機器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復(fù)必須使用導(dǎo)入來加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來自特定服務(wù)器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復(fù)“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務(wù)器時的歡迎消息)
主站蜘蛛池模板: 日韩欧美一级片 | 日本不卡一区二区三区在线观看 | 91精品国产高清一区二区三区 | 日日操视频 | 中文字幕精品视频 | 中文字幕一区二区三区不卡在线 | 精品一二区 | 欧美情趣视频 | 91在线中文字幕 | 日韩精品免费 | 日本a∨精品中文字幕在线 亚洲91视频 | 中文字幕在线网 | 亚洲综合在线视频 | 91成人免费电影 | 日韩成人一区 | 欧美国产视频 | 久久久久久久电影 | 男女羞羞视频网站 | 中文字幕一区二区三区日韩精品 | 欧美操操操 | 99久久免费精品国产男女高不卡 | 99re在线视频观看 | 九九久久久| 嫩草视频在线看 | 天天天操操操 | 久久久精彩视频 | 亚洲精品乱码久久久久v最新版 | 国产欧美精品区一区二区三区 | 免费在线观看成人 | a级毛片基地| 久久毛片 | 免费一区二区三区 | 国产精品久久久久久中文字 | 涩涩视频网站在线观看 | 免费1区2区3区 | 国产91视频免费 | 亚洲精品国产电影 | 国产成人a亚洲精品 | 亚洲一区二区网站 | 99久久中文字幕三级久久日本 | 少妇一级淫片免费放播放 |