Compare commits

...

2 commits

Author SHA1 Message Date
1b402c791c execution: log channel ID to terminal if it's unknown
channelId is set for commands executed outside of common guilds
no changes for usage logging in database is required
2024-04-26 08:13:29 +02:00
c4edf55f65 commands/ask: enforce userLimit 2024-04-26 08:07:46 +02:00
2 changed files with 19 additions and 2 deletions

View file

@ -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[] = [

View file

@ -191,7 +191,8 @@ function logUsedTokens(
// it doesn't make sense to store usage in database if we don't know where it came from
return;
}
const channelName: string = !message.channel ? "[No channel]"
const channelName: string = !message.channelId ? "[No channel]"
: !message.channel ? `[Unknown channel: ${message.channelId}]`
: !message.channel.isDMBased() ? `#${message.channel.name} (${message.guild?.name})`
: `#@${getAuthor(message).tag}`
;