Search code examples
javascriptdiscord.jscommando

How to fix "DeprecationWarning: Collection#filterArray: use Collection#filter"?


I'm setting up a new discord bot, and want to join a voice channel. When I write the command !join, the terminal sends me this message:

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;

Solution

  • That is just a warning, not an error: your code is not being affected by it, you can just ignore it.
    There's an open issue on GitHub (link) that says it's a bug caused by the internal use of a discord.js method that has been marked as deprecated. One of the developers said that they'll fix that in a future release, for now just ignore it.