Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

250
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!