久久久久久久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 服務器時的歡迎消息)
主站蜘蛛池模板: 日韩久久精品 | 亚洲 日本 欧美 中文幕 | 国产一区二区三区久久久久久久久 | 国产激情视频在线观看 | 91av在线免费看 | 日韩欧美国产精品一区 | 91av亚洲 | 欧美日韩亚洲视频 | 野狼在线社区2017入口 | 9色网站 | 日韩精品一区二区三区中文字幕 | 天天操夜夜操 | 免费观看日韩av | 免费同性女女aaa免费网站 | 一区二区中文字幕 | 久久国产精品网站 | 久久大陆 | 黄色免费av | jizz18国产 | 日韩国产一区 | 国产精品视屏 | 国产在线精品一区二区 | 亚洲人成人一区二区在线观看 | 一级片在线视频 | 亚洲人成在线播放 | av一区二区三区四区 | 男人的天堂在线视频 | 中文字幕一级毛片视频 | 中文字幕日韩欧美一区二区三区 | 亚洲精品一区中文字幕乱码 | 国产在线一区观看 | 久久一区二区三区四区 | 国产高清视频在线播放 | 爱爱综合网 | 久久亚洲一区二区三区四区 | 久久国产一区 | 久久国产精品视频 | 久久成人精品视频 | 亚洲午夜网 | 情侣酒店偷拍一区二区在线播放 | 综合精品久久久 |