- 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.
32 lines
805 B
TypeScript
32 lines
805 B
TypeScript
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,
|
|
locale: Locale
|
|
): Promise<boolean> {
|
|
const member = interaction.memberPermissions;
|
|
if (!member?.has(permission)) {
|
|
await interaction.reply({
|
|
content: t(locale, 'generic.noPermission'),
|
|
ephemeral: true
|
|
});
|
|
return false;
|
|
}
|
|
|
|
if (!interaction.guild?.members.me?.permissions.has(permission)) {
|
|
await interaction.reply({
|
|
content: t(locale, 'generic.botMissingPermission').replace(
|
|
'{permission}',
|
|
permission.toString()
|
|
),
|
|
ephemeral: true
|
|
});
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|