Throttling is like rate-limiting, it only allows the command to be used in a certain period of time. A cooldown of sorts. They're very simple, as with most things I've explained in Commando.
Let's (for the millionth time) grab our say command's properties.
super(client, {
name: 'say',
aliases: ['copycat', 'repeat', 'echo', 'parrot'],
group: 'group2',
memberName: 'say',
description: 'Replies with the text you provide.',
examples: ['say Hi there!'],
args: [
{
key: 'text',
prompt: 'What text would you like the bot to say?',
type: 'string'
}
]
});
Now, let's add throttling
to the command. throttling
is an object, which contains two things:
usages
is the amount of times the command can be used in the given time period.
duration
is the amount of time the cooldown lasts, in seconds.
Let's make it have 2 usages allowed in a 10 second period.
super(client, {
name: 'say',
aliases: ['copycat', 'repeat', 'echo', 'parrot'],
group: 'group2',
memberName: 'say',
description: 'Replies with the text you provide.',
examples: ['say Hi there!'],
throttling: {
usages: 2,
duration: 10
},
args: [
{
key: 'text',
prompt: 'What text would you like the bot to say?',
type: 'string'
}
]
});
And now the command has a cooldown.