Is there any way to delete more than 100 messages at once in Discord.js?

Solution for Is there any way to delete more than 100 messages at once in Discord.js?
is Given Below:

currently im making a Discord Bot but im having troubles, I don’t know how to delete more than 100 messages in discord.js, since limit its 100, Im looking for functions that will help me with my issue, my current code its:

const Discord = require("discord.js");
const { Client, MessageEmbed } = require("discord.js");

module.exports = {
  name: "purge",
  alias: [],
  devOnly: false,
  guildOnly: true,
  nsfwOnly: false,
  botPermissions: [
    "SEND_MESSAGES",
    "ATTACH_FILES",
    "VIEW_CHANNEL",
    "MANAGE_MESSAGES",
  ],
  userPermissions: ["SEND_MESSAGES", "MANAGE_MESSAGES"],
  category: "Moderation",
  usage: "clear (messages)",
  description: "Deletes the specified amount of messages",
  run: async (client, message, args) => {
    let prefix = await client.prefix(message);
    let member = message.mentions.members.first();

    if (!message.guild.me.permissions.has("MANAGE_MESSAGES"))
      return message.channel.send(
        new Discord.MessageEmbed()
          .setDescription(
            `<:no:860978971771928647> ***I don't have the necessary permissions to do that, please use the command `${prefix}setup` to check all it's working correctly.***`
          )
          .setColor(16711680)
      );

    if (!message.member.hasPermission("MANAGE_MESSAGES"))
      return message.channel.send(
        new Discord.MessageEmbed()
          .setDescription(
            "<:no:860978971771928647> ***You don't have the necessary permissions to do that.***"
          )
          .setColor(16711680)
      );

    if (member) {
      const userMessages = (await messages).filter(
        (m) => m.author.id === member.id
      )

      await message.channel.bulkDelete(userMessages)
      message.channel.send(new Discord.MessageEmbed()
        .setDescription(`<:si:860978510079852544> ***${member} messages has been cleared.***`)
        .setColor('GREEN')
      )
    } else {
      let mensajes = parseInt(args[0]);
      if (!mensajes)
        return message.channel.send(
          new Discord.MessageEmbed()
            .setDescription(
              "<:no:860978971771928647> ***Please provide a amount of messages to delete, it needs to be a number***"
            )
            .setColor(16711680)
        );
      if (mensajes < 1)
        return message.channel.send(
          new Discord.MessageEmbed()
            .setDescription(
              "<:no:860978971771928647> ***The arguments provided are not correctly, the amount of messages must be greater than 1***"
            )
            .setColor(16711680)
        );
      let embedlimitmessages = new Discord.MessageEmbed()
        .setDescription(
          "<:no:860978971771928647> ***You can't delete more than 100 messages**"
        )
        .setColor(16711680);
      if (mensajes > 100) return message.channel.send(embedlimitmessages);
      message.delete();
      message.channel.bulkDelete(mensajes);
      let embed = new Discord.MessageEmbed()
        .setDescription(
          `<:si:860978510079852544> ***I deleted ${mensajes} messages successfully!***`
        )
        .setColor("GREEN");
      message.channel.send(embed).then((m) => m.delete({ timeout: 10000 }));
    }
  },
};

I was reading in other forums for how to do it, also I looked up in Discord Help Servers, and they say with a for or a while i can do that to don’t make API abuse, i would appreciate you guys can give me an example

NOTE: you should still keep a max amount on this

Discord.TextChannel.prototype._bulkDelete = async function(amount) {
    if(amount > MAX_HERE) return;
    for (let i = amount; i > 0; i-=100) {
        if (i > 100) { 
            this.bulkDelete(100);
        } else {
            this.bulkDelete(i)
        }
    }
}
//you can now call the function on a text channel and put more than 100 if your new cap is higher

This code is creating an _bulkDelete method for all Discord text channels. I did not test this however, so if you get any errors, just tell me!

Notes: Replace MAX_HERE with your new cap. You may also get ratelimited. Maybe you want to add a “sleep” function to avoid being ratelimited.