/check-limit: show when the user can use the bot again by default
fixes #12
This commit is contained in:
parent
80f4f18eab
commit
49b074f98e
1 changed files with 12 additions and 1 deletions
|
@ -22,9 +22,20 @@ export default class MyLimit extends Command implements Command {
|
|||
];
|
||||
|
||||
async execute(interaction: ChatInputCommandInteraction) {
|
||||
let recoveryFor = interaction.options.getInteger("recovery-for", false) ?? 1;
|
||||
let recoveryFor = interaction.options.getInteger("recovery-for", false);
|
||||
const ephemeral = interaction.options.getBoolean("ephemeral", false) ?? true;
|
||||
|
||||
if (recoveryFor === null) {
|
||||
const userQuota = await config.quota.checkUser(
|
||||
interaction.user,
|
||||
interaction,
|
||||
);
|
||||
const remaining = userQuota.quota - userQuota.used;
|
||||
// NOTE: In order for user to execute the bot again, the used must be lower than quota
|
||||
// user can't execute if quota and used are equal
|
||||
// thus why we add 1 here
|
||||
recoveryFor = remaining >= 0 ? 1 : 1 - remaining;
|
||||
}
|
||||
if (recoveryFor <= 0) recoveryFor = 1;
|
||||
|
||||
const userQuotaRecovery = await config.quota.getUserQuotaRecovery(interaction.user, interaction, recoveryFor);
|
||||
|
|
Loading…
Reference in a new issue