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
|
// Check the ratelimit
|
||||||
const doRateLimit = ratelimiter.check(interaction.user, commandName, command);
|
const doRateLimit = ratelimiter.check(userID, commandName, command);
|
||||||
if (doRateLimit) {
|
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 });
|
return interaction.reply({ content: doRateLimit, ephemeral: true });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -313,7 +313,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the ratelimit
|
// Check the ratelimit
|
||||||
const doRateLimit = ratelimiter.check(message.author, commandName, command);
|
const doRateLimit = ratelimiter.check(userID, commandName, command);
|
||||||
if (doRateLimit) {
|
if (doRateLimit) {
|
||||||
return message.reply({ content: doRateLimit, ephemeral: true });
|
return message.reply({ content: doRateLimit, ephemeral: true });
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ export default {
|
||||||
once: true,
|
once: true,
|
||||||
async execute(client) {
|
async execute(client) {
|
||||||
// Init global variables.
|
// Init global variables.
|
||||||
|
global.ratelimit = {};
|
||||||
global.boards = {};
|
global.boards = {};
|
||||||
|
|
||||||
const ytdlpVersion = await new Promise((resolve, reject) => {
|
const ytdlpVersion = await new Promise((resolve, reject) => {
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
const ratelimit = {};
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
check,
|
check,
|
||||||
};
|
};
|
||||||
function check(user, commandName, commands) {
|
function check(userID, commandName, commands) {
|
||||||
const userID = user.id;
|
const ratelimit = global.ratelimit;
|
||||||
const userTag = user.tag;
|
|
||||||
|
|
||||||
if (!ratelimit[userID]) {
|
if (!ratelimit[userID]) {
|
||||||
ratelimit[userID] = {};
|
ratelimit[userID] = {};
|
||||||
}
|
}
|
||||||
|
@ -21,7 +17,6 @@ function check(user, commandName, commands) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (commands.ratelimit === ratelimit[userID][commandName].limit) {
|
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.`;
|
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