From c4edf55f656ce0bb8ffe928c3f15e99124bfc94b Mon Sep 17 00:00:00 2001 From: Wroclaw Date: Fri, 26 Apr 2024 08:07:46 +0200 Subject: [PATCH] commands/ask: enforce userLimit --- src/commands/ask.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/commands/ask.ts b/src/commands/ask.ts index ea39da7..d5a1d30 100644 --- a/src/commands/ask.ts +++ b/src/commands/ask.ts @@ -56,7 +56,23 @@ export default class Ask extends Command implements Command { }); return; } - + + const userLimit = await config.quota.checkUser(interaction.user, interaction); + + if (userLimit.used >= userLimit.quota) { + interaction.reply({ + + embeds: [{ + color: 0xff0000, + description: "You've used up your quota,\n" + userLimit.toString(), + }], + ephemeral: true, + }).catch(e => { + console.error("Failed to reply to user: ", e); + }); + return; + } + // TODO: check content in moderation API const messages: ChatCompletionMessageParam[] = [