Update ESLint rules, enhance environment schema with new metrics and health port, and refactor Redis import. Change TypeScript definitions path in package.json.
This commit is contained in:
27
apps/bot/src/permissions.ts
Normal file
27
apps/bot/src/permissions.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { type ChatInputCommandInteraction } from 'discord.js';
|
||||
import { t } from '@nexumi/shared';
|
||||
|
||||
export async function requirePermission(
|
||||
interaction: ChatInputCommandInteraction,
|
||||
permission: bigint
|
||||
): Promise<boolean> {
|
||||
const locale = 'de';
|
||||
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: `Bot lacks required permission (${permission.toString()}).`,
|
||||
ephemeral: true
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user