Enhance moderation commands with locale support and permission checks

- Updated moderation commands to utilize locale for user-facing messages, improving internationalization.
- Refactored permission checks to include locale as a parameter, ensuring accurate responses based on the server's language settings.
- Added new translation keys for bot permissions and command restrictions in both German and English.
This commit is contained in:
smueller
2026-07-22 11:23:10 +02:00
parent 39a47074ae
commit a17d161c06
5 changed files with 153 additions and 56 deletions

View File

@@ -1,11 +1,12 @@
import { type ChatInputCommandInteraction } from 'discord.js';
import { t } from '@nexumi/shared';
import type { Locale } from '@nexumi/shared';
export async function requirePermission(
interaction: ChatInputCommandInteraction,
permission: bigint
permission: bigint,
locale: Locale
): Promise<boolean> {
const locale = 'de';
const member = interaction.memberPermissions;
if (!member?.has(permission)) {
await interaction.reply({
@@ -17,7 +18,10 @@ export async function requirePermission(
if (!interaction.guild?.members.me?.permissions.has(permission)) {
await interaction.reply({
content: `Bot lacks required permission (${permission.toString()}).`,
content: t(locale, 'generic.botMissingPermission').replace(
'{permission}',
permission.toString()
),
ephemeral: true
});
return false;