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

在 discord.js 中的時間限制之前獲取收集的消息

Get collected message before time limit in discord.js(在 discord.js 中的時間限制之前獲取收集的消息)
本文介紹了在 discord.js 中的時間限制之前獲取收集的消息的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

有沒有辦法在時間限制到期之前接收來自 discord.js 收集器的消息?

Is there a way to receive messages from discord.js collectors before the time limit expires?

我嘗試使用collector.on collect,但它在我設置的時間限制后觸發.

I tried using collector.on collected, but it triggered after the time limit I set.

這是我目前擁有的:

this.collected = false
        this.collector = new Discord.MessageCollector(msg.channel, m => m.author.bot === false,{time: 10000});
        this.collector.on('collect', message =>{
            if(!this.collected){
                this.collected = true
                console.log(message)
                msg.channel.send(message.content)
                this.collector.stop()
               //Insert the same thing here(Copy+Paste the same code here)
            }
        });

(所有的 this 都是為了全局,因為它必須是遞歸的)

(The this on everything is for globality, it's because it has to be recursive)

我希望收集器在收到第一條消息時發出一個事件,但使用當前代碼它只在時間限制之后才會這樣做.

I want the collector to emit an event on the moment it receiveves the first message, but with the current code it only does that after the time limit.

推薦答案

經過一些測試,collect 事件僅在 集合 time 選項已達到.似乎它實際上并沒有在收到消息時收集消息,而是在計時器用完時收集消息.這是否是故意的,我不確定.

After some testing, it appears that the collect event is only emitted after the set time option is reached. It seems as though it's not actually collecting the messages when they're received, but instead when the timer runs out. Whether this is intentional or not, I'm not sure.

由于你只需要一定數量的消息,你可以設置 maxMatches 收集器的選項.然后,如果在達到 time 限制之前收集到該數量的消息,則收集器將發出 collect 事件并停止.

Since you only need a certain amount of messages, you can set the maxMatches option of your collector. Then, if that amount of messages is collected before the time limit is reached, the collector will emit the collect event and stop.

this.collector = new Discord.MessageCollector(msg.channel, m => !m.author.bot, { maxMatches: 1, time: 10000 });

this.collector.on('collect', message => {
  msg.channel.send(message.content)
    .catch(console.error);
});

這篇關于在 discord.js 中的時間限制之前獲取收集的消息的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

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(如何讓我的機器人提及發出該機器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復必須使用導入來加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來自特定服務器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務器時的歡迎消息)
主站蜘蛛池模板: 久久综合一区二区 | 夏同学福利网 | 亚洲精品一区二区在线观看 | 久久成人精品 | 黑人中文字幕一区二区三区 | 91资源在线 | 521av网站 | 亚洲精品国产电影 | 7777奇米影视 | 日韩一区二区三区四区五区六区 | 国产午夜精品视频 | 在线观看国产视频 | 免费大黄视频 | 黄久久久 | 99精品视频网 | 亚洲精品一区二区三区在线 | 中文字幕欧美在线观看 | 国产精品明星裸体写真集 | 99久久精品免费 | 成人在线看片 | 久在线 | 欧美激情啪啪 | 国产乱码精品1区2区3区 | 亚洲综合视频 | 91色网站 | 网络毛片 | 欧美日韩一区二区在线 | 在线播放一区二区三区 | www亚洲免费国内精品 | 台湾佬成人网 | 鲁一鲁资源影视 | 天天天天天操 | 午夜精品一区二区三区在线观看 | 欧洲国产精品视频 | 亚洲精品国产电影 | 性色av一区 | 国产婷婷精品av在线 | www.xxxx欧美 | 欧美 日韩 国产 成人 | 久草视频在线看 | av无遮挡|