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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user