Compare commits
2 commits
afdbbee495
...
7254a242db
Author | SHA1 | Date | |
---|---|---|---|
7254a242db | |||
d225d7037c |
4 changed files with 11 additions and 6 deletions
|
@ -52,8 +52,9 @@ export default {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Check the ratelimit
|
// Check the ratelimit
|
||||||
const doRateLimit = ratelimiter.check(userID, commandName, command);
|
const doRateLimit = ratelimiter.check(interaction.user, 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(userID, commandName, command);
|
const doRateLimit = ratelimiter.check(message.author, commandName, command);
|
||||||
if (doRateLimit) {
|
if (doRateLimit) {
|
||||||
return message.reply({ content: doRateLimit, ephemeral: true });
|
return message.reply({ content: doRateLimit, ephemeral: true });
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ 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,8 +1,12 @@
|
||||||
|
const ratelimit = {};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
check,
|
check,
|
||||||
};
|
};
|
||||||
function check(userID, commandName, commands) {
|
function check(user, commandName, commands) {
|
||||||
const ratelimit = global.ratelimit;
|
const userID = user.id;
|
||||||
|
const userTag = user.tag;
|
||||||
|
|
||||||
if (!ratelimit[userID]) {
|
if (!ratelimit[userID]) {
|
||||||
ratelimit[userID] = {};
|
ratelimit[userID] = {};
|
||||||
}
|
}
|
||||||
|
@ -17,6 +21,7 @@ function check(userID, 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.`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,4 +36,4 @@ function check(userID, commandName, commands) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
Loading…
Reference in a new issue