简体   繁体   中英

Why is discord.js purge command not responding?

I'm trying to make a discord.js bot. I'm getting stuck on the purge command. When I test it it either takes over a minute to respond or it doesn't work at all.

Javascript code:

if (!message.member.hasPermission("MANAGE_MESSAGES"))
return message.reply("You don't have permssions to do that!");
if (!args[0])
  return message.channel.send(
    "Please enter a number of messages to clear! `Usage: .clear <amount>`"
  );
const deleteNum = parseInt(args[0])
if (isNaN(deleteNum)) return message.reply('that is not a number')
message.channel.bulkDelete(deleteNum).then(() => {
  message.channel
    .send(`**__Cleared ${args[0]} messages.__**`)
    .then(msg => msg.delete(5000));
});

Is it just purge or is it all commands? If it is all commands then use this:

message.channel.send(`Latency is ${Date.now() - message.createdTimestamp}ms.`)

If the ping is high then it is an issue on your end. Else, you might need to look into more efficient/better ways of doing this. If you'd like to, you can reply with your ping and if it is not the ping's fault then I'd be happy to help anymore:D

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM