#Command Cooldown
1 messages · Page 1 of 1 (latest)
so what you can do
is make it so that
it loads all the command names
into a map
with a number
then you can load the map into discord by doing client.commandmap = themap;
then in each command
you can mess with maps here
just a few lines
that teach you about it
Ok so continue
so you load the map into discord
because you can do that with any module
doesnt even have to be discord
but
then in the command you want to have a delay
oh
you also would have to make the map display who executed it with their id
so in the command file
it will check if the command is 0
and if its 0
it will execute no problem
but if its 1 it will say that there is a delay
and you make it so the map number
resets
each time
like
each minute
or something
How
in your cmd handler
does it log
when the msg
is made
sorry
when the command
is loaded
Yeah
like blahblah.js is loaded
yeah
so you can do
mapname.set(interaction.user, [everyloadedcommand: "0"])
so like
that as an example
it makes an object in the map
with ur id
with every command name
and 0
then when you execute the command
Ohhhhhh
you make it add 1
to the 0
and if its 1
it sends an error
then you just make it reset back to 0 after however long
you want the cooldown
to be
So when the bot logs that the command has loaded it will also set all the commands to 0 in the map
ya
How do I do that?
so for that
setTimeout(function() {
map.set((interaction.user).specificcommand, 0)
}, timeuntilresetnumberhere);
send the command handler
const fs = require('fs');
fs.readdirSync('./src/Commands').filter(file => file.endsWith('js')).forEach(file =>{
/**
* @type {Command}
*/
const command = require(`../Commands/${file}`)
console.log(`Command ${command.name} has loaded!`)
this.commands.set(command.name, command)
});
I have 4 minutes eeeeeeee
3
2
1
@worldly aurora Gtg you can send how to do it but I won't see it till morning. Thank you for your help!