forked from Supositware/Haha-Yes
make optout work here
This commit is contained in:
parent
f29d721771
commit
29e97c27f6
1 changed files with 9 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
||||||
const ratelimit = {};
|
const ratelimit = {};
|
||||||
|
import db from '../models/index.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
check,
|
check,
|
||||||
|
@ -25,7 +26,14 @@ function check(user, commandName, commands) {
|
||||||
const minutes = Math.floor(seconds / 60);
|
const minutes = Math.floor(seconds / 60);
|
||||||
const hours = Math.floor(minutes / 60);
|
const hours = Math.floor(minutes / 60);
|
||||||
const dateString = `${hours > 0 ? ` ${Math.floor(hours)} hours` : ''}${minutes > 0 ? ` ${Math.floor(minutes % 60)} minutes` : ''}${seconds > 0 ? ` ${Math.floor(seconds % 60)} seconds` : ''}`;
|
const dateString = `${hours > 0 ? ` ${Math.floor(hours)} hours` : ''}${minutes > 0 ? ` ${Math.floor(minutes % 60)} minutes` : ''}${seconds > 0 ? ` ${Math.floor(seconds % 60)} seconds` : ''}`;
|
||||||
console.log(`\x1b[33m${userTag} (${userID})\x1b[0m is rate limited on \x1b[33m${commandName}\x1b[0m for${dateString}.`);
|
|
||||||
|
const isOptOut = db.optout.findOne({ where: { userID: userID } });
|
||||||
|
if (isOptOut) {
|
||||||
|
console.log(`A user is rate limited on \x1b[33m${commandName}\x1b[0m for${dateString}.`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log(`\x1b[33m${userTag} (${userID})\x1b[0m is rate limited on \x1b[33m${commandName}\x1b[0m for${dateString}.`);
|
||||||
|
}
|
||||||
return `You are being rate limited. You can try again in${dateString}.`;
|
return `You are being rate limited. You can try again in${dateString}.`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue