Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

244
Vistas
Missing Permissions when using bulkDelete() on the bot's own messages

I'm trying to implement a command to delete the bot's N last messages in a channel. The bot does not have MANAGE_MESSAGES permission. When N = 1, the bot deletes its latest message, as intended. However, when N > 1, the bot throw the error:

D:\Seneca\7th_Term\DPS909\EarTensifier\node_modules\discord.js\src\rest\RequestHandler.js:170
          return reject(new DiscordAPIError(request.path, data, request.method, res.status));
                        ^

DiscordAPIError: Missing Permissions
    at RequestHandler.execute (D:\Seneca\7th_Term\DPS909\EarTensifier\node_modules\discord.js\src\rest\RequestHandler.js:170:25)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {      
  method: 'post',
  path: '/channels/757408200973877277/messages/bulk-delete',
  code: 50013,
  httpStatus: 403
}

What is weird to me is that how come the bot be able to delete 1 of its message, but not more? When I tested the same code with MANAGE_MESSAGES enabled, it works perfectly. Is it possible to implement this functionality without the MANAGE_MESSAGES permission, since I only want the bot to delete its own messages, not others'?

Here is my implementation:

const botID = process.env.DISCORD_ID;
if (message.channel.type == 'text') {
    await message.channel.messages.fetch({limit: 100}).then(messages => {
        let botMessages = messages.filter(msg => msg.author == botID).array();
        if (no_of_messages > 0){
            botMessages.splice(no_of_messages);
        }
        message.channel.bulkDelete(botMessages);
        client.log(`Deleted ${botMessages.length} messages from ${botID}`)
    }).catch(err => {
        client.log('Error while doing Bulk Delete');
        client.log(err);
    });
}
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda