Compare commits
1 commit
7254a242db
...
afdbbee495
Author | SHA1 | Date | |
---|---|---|---|
afdbbee495 |
4 changed files with 6 additions and 11 deletions
|
@ -52,9 +52,8 @@ export default {
|
|||
*/
|
||||
|
||||
// Check the ratelimit
|
||||
const doRateLimit = ratelimiter.check(interaction.user, commandName, command);
|
||||
const doRateLimit = ratelimiter.check(userID, commandName, command);
|
||||
if (doRateLimit) {
|
||||
console.log(`\x1b[33m${userTag} (${userID})\x1b[0m is rate limited on \x1b[33m${commandName}\x1b[0m for ${ratelimiter.timeLeft(userID, commandName)} seconds`);
|
||||
return interaction.reply({ content: doRateLimit, ephemeral: true });
|
||||
|
||||
}
|
||||
|
|
|
@ -313,7 +313,7 @@ export default {
|
|||
}
|
||||
|
||||
// Check the ratelimit
|
||||
const doRateLimit = ratelimiter.check(message.author, commandName, command);
|
||||
const doRateLimit = ratelimiter.check(userID, commandName, command);
|
||||
if (doRateLimit) {
|
||||
return message.reply({ content: doRateLimit, ephemeral: true });
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ export default {
|
|||
once: true,
|
||||
async execute(client) {
|
||||
// Init global variables.
|
||||
global.ratelimit = {};
|
||||
global.boards = {};
|
||||
|
||||
const ytdlpVersion = await new Promise((resolve, reject) => {
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
const ratelimit = {};
|
||||
|
||||
export default {
|
||||
check,
|
||||
};
|
||||
function check(user, commandName, commands) {
|
||||
const userID = user.id;
|
||||
const userTag = user.tag;
|
||||
|
||||
function check(userID, commandName, commands) {
|
||||
const ratelimit = global.ratelimit;
|
||||
if (!ratelimit[userID]) {
|
||||
ratelimit[userID] = {};
|
||||
}
|
||||
|
@ -21,7 +17,6 @@ function check(user, commandName, commands) {
|
|||
}
|
||||
|
||||
if (commands.ratelimit === ratelimit[userID][commandName].limit) {
|
||||
console.log(`\x1b[33m${userTag} (${userID})\x1b[0m is rate limited on \x1b[33m${commandName}\x1b[0m for ${Math.floor((ratelimit[userID][commandName].cooldown - date) / 1000)} seconds`);
|
||||
return `You are being rate limited. You can try again in ${Math.floor((ratelimit[userID][commandName].cooldown - date) / 1000)} seconds.`;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue