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

163
Views
¿Por qué mi comando de purga está eliminando todos los mensajes en el chat y no el número dado?

Estoy trabajando en mi bot desde hace algún tiempo, y estoy trabajando en un comando de purga. El único problema es que el bot está borrando todos los mensajes del chat. No es el número dado. Aquí está el código:

 const { Permissions } = require('discord.js'); const { Client, Intents } = require('discord.js'); const client = new Client({ intents: [Intents.FLAGS.GUILDS] }); const Discord = require('discord.js'); module.exports = { name: 'purge', description: 'Deletes a amount of messages in the chat.', admin: true, async execute(message, args){ if (!message.member.permissions.has(Permissions.FLAGS.MANAGE_MESSAGES)) return message.channel.send("You don't have the permissions to execute this command."); if(!args[0]) return message.reply("Please enter the amount of messages you wish to delete."); if(isNaN(args[0])) return message.reply("The specified charecters are not numbers, please enter a real number."); if(args[0] > 100) return message.reply("Enter a valid amount between 2 and 100."); if(args[0] < 1) return message.reply("You entered a value below 0, enter a value above 0."); await message.channel.messages.fetch({limit: args[1]}).then(messages =>{ message.channel.bulkDelete(messages, true) }); } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Este es el que funciona correctamente!

 const { Permissions } = require('discord.js'); const { Client, Intents } = require('discord.js'); const client = new Client({ intents: [Intents.FLAGS.GUILDS] }); const Discord = require('discord.js'); module.exports = { name: 'purge', description: 'Deletes a amount of messages in the chat.', admin: true, async execute(message, args){ if (!message.member.permissions.has(Permissions.FLAGS.MANAGE_MESSAGES)) return message.channel.send("You don't have the permissions to execute this command."); if(!args[0]) return message.reply("Please enter the amount of messages you wish to delete."); if(isNaN(args[0])) return message.reply("The specified charecters are not numbers, please enter a real number."); if(args[0] > 100) return message.reply("Enter a valid amount between 2 and 100."); if(args[0] < 1) return message.reply("You entered a value below 0, enter a value above 0."); await message.channel.messages.fetch({limit: args[0]}).then(messages =>{ message.channel.bulkDelete(messages, true) }); } }
about 4 years ago · Juan Pablo Isaza Report
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!