Skip to content Skip to sidebar Skip to footer

How Does BulkDelete Work?

I tried using bulkDelete to make my bot delete its message but I get this error: (node:5724) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error:

Solution 1:

The easiest way to delete x messages from a channel is to provide an integer from 2 - 100 as parameters to the <TextChannel>.bulkDelete method.

Example:

message.channel.bulkDelete(100).then(() => {
  message.channel.send("Deleted 100 messages.").then(msg => msg.delete(3000));
});

Solution 2:

The discord bulk delete endpoint requires the array of messages you would like deleted. Small note here as of yesterday the bulk delete endpoint will not remove messages older than 2 weeks.


Solution 3:

Here is a bit more updated one;

    }else if (command === 'purge') {
    const amount = parseInt(args[0]);

    if (isNaN(amount)) {
        return message.reply('that doesn\'t seem to be a valid number.');
    }

    if (isNaN(amount)) {
    return message.reply('You have enterd a invalid amount. Try ``purge 5``');
} else if (amount < 2 || amount > 100) {
    return message.reply('you need to input a number between 2 and 100.');
}
message.channel.bulkDelete(amount);
message.channel.send(amount + ' ' +'messages deleted');

    }
});

Post a Comment for "How Does BulkDelete Work?"