Reputation: 358
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));
});
Upvotes: 0
Views: 96
Reputation: 57
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
Upvotes: 1