Skip to content

Commit

Permalink
Add permission check to expense command
Browse files Browse the repository at this point in the history
  • Loading branch information
ryandward committed Apr 3, 2024
1 parent a4d162c commit 09c7a69
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions commands/bank/expense.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ export const data = new SlashCommandBuilder()

export async function execute(interaction: CommandInteraction) {
try {
// Check if the member has the required roles
const member = await interaction.guild?.members.fetch(interaction.user.id);
const hasPermission = member?.roles.cache.some(
role => role.name === 'Officer' || role.name === 'Treasurer',
);
if (!hasPermission) {
throw new Error('You do not have permission to use this command.');
}

const { options } = interaction;
const amount = options.get('amount')?.value as number;
const description = options.get('description')?.value as string;
Expand Down

0 comments on commit 09c7a69

Please sign in to comment.