如何修复“ DeprecationWarning:Collection#filterArray:使用Collection#filter”?

时间:2019-01-18 23:20:34

标签: javascript discord.js commando

我正在建立一个新的Discord机器人,并想加入一个语音频道。当我编写命令!join时,终端向我发送以下消息:

DeprecationWarning: Collection#filterArray: use Collection#filter instead.
const commando = require('discord.js-commando');

class JoinChannelCommand extends commando.Command {
  constructor(client) {
    super(client, {
      name: 'join',
      group: 'music',
      memberName: 'join',
      description: 'Joins the voice channel of the commander'
    });
  }

  async run(message, args) {
    if (message.member.voiceChannel) {
      if (!message.guild.voiceConnection) {
        message.member.voiceChannel.join()
          .then(connection => {
            message.reply("Successfully Joined!");
          });
      }
    } else {
      message.reply("You must be in a vocie channel to summon me!");
    }
  }
}

module.exports = JoinChannelCommand;

1 个答案:

答案 0 :(得分:0)

那只是警告,而不是错误:您的代码不受它的影响,您可以忽略它。
GitHub(link)上有一个未解决的问题,它是由内部使用discord.js方法(已标记为已弃用)引起的错误。一位开发人员表示,他们将在将来的版本中修复此问题,暂时请忽略它。