【问题标题】:ERROR message.guild.channels.filter is not a function, using Discord.JS错误 message.guild.channels.filter 不是函数,使用 Discord.JS
【发布时间】:2020-08-05 13:50:09
【问题描述】:

我正在使用 discord.js 开发 Discord 机器人。我希望他在我输入 !play 时播放 MP3。 但我有一条错误消息“message.guild.channels.filter”。我是这个领域的菜鸟,我不明白为什么。代码:


module.exports = class Play extends Command {
    static match(message) {
        return message.content.startsWith('!play')
    }

    static action (message){
       let voiceChannel =  message.guild.channels
        .filter(function (channel) {return channel.type === 'voice'})
        .first()
        voiceChannel
        .join()
        .then(function (connection){
            connection.playFile('./ah.mp3')
        })
    }
}

【问题讨论】:

    标签: javascript bots discord discord.js


    【解决方案1】:

    从 discord.js v12 开始,您现在需要使用 .cache 来访问 channels 集合。

    请改用client.channels.cache.filter()

    【讨论】:

      猜你喜欢
      • 2021-12-24
      • 2021-05-31
      • 2020-07-24
      • 2021-01-26
      • 1970-01-01
      • 2021-07-06
      • 2020-12-31
      • 2020-12-07
      • 2020-08-23
      相关资源
      最近更新 更多