discord.js-textChannel中的awaitMessages

时间:2020-05-01 20:06:03

标签: discord.js

我想用discord.js做一个awaitMessages,但是出现错误。这是我的代码:

message.channel.send('hello').then(msg => {
                message.channel.awaitMessages(msg, { 
                    max: 1, 
                    time: 10000, 
                    errors: ['time'] })

                    .then(collected => message.channel.send('this is a test'))

                    .catch(collected => msg.delete());
            });

这是我的错误:

if (collect && this.filter(...args, this.collected)) {
                                             ^

TypeError: Function.prototype.apply was called on [object Object], which is a object and not a function

2 个答案:

答案 0 :(得分:0)

awaitMessages中的第一个参数是过滤器功能,而不是消息对象。

docs

答案 1 :(得分:0)

您应该尝试类似的操作:

message.channel.send('hello').then(msg => {
                message.channel.awaitMessages(m => m.author.id === msg.author.id, { 
                    max: 1, 
                    time: 10000, 
                    errors: ['time'] })

                    .then(collected => message.channel.send('this is a test'))

                    .catch(collected => msg.delete());
            });