Code is functional, but spits out errors in my console when ran

The following code is a command to clear 15 messages from a user, and it’s entirely functional, but when I use the command to clear messages, I start getting flooded with error messages in my console.


The code for the command is:

const Discord = require('discord.js')
const EmbedHelper = require('../include/embeds.js')
const Logger = require('../include/globals.js') = async (client, message, args, config) => {{ limit: 15 }).then(messages => {
        let array = messages.array();
        array = array.filter(m => ===;
        array.length = 15 + 1; => m.delete().catch(console.log))
    log(`Deleting 15 messages from chat`)


You’re trying to overwrite the length of the array.

Use to delete the messages. Also note that bots can’t delete messages more than 2 weeks old.

1 Like