diff --git a/app/lib/discord/bot.ts b/app/lib/discord/bot.ts index bb1e005..a5be830 100644 --- a/app/lib/discord/bot.ts +++ b/app/lib/discord/bot.ts @@ -40,7 +40,6 @@ export class Bot extends REST { super(options); this.applicationId = getEnvironment().discordClientId; - this.edgedb = edgedb; this.token = token; this.setToken(this.token); @@ -57,6 +56,19 @@ export class Bot extends REST { processInteraction( interaction: APIBaseInteraction ): InteractionPromise { + if ( + !interaction?.member?.roles.some((role) => + getEnvironment().authorizedRoleIds.includes(role) + ) + ) { + return InteractionPromise.resolve( + this.errorResponse( + `You do not have permission to run this command`, + true + ) + ); + } + switch (interaction.type) { case InteractionType.ApplicationCommand: const command = interaction as APIBaseInteraction< @@ -65,8 +77,9 @@ export class Bot extends REST { >; if (!command.data) { - console.error("No command data found"); - return InteractionPromise.resolve(this.errorResponse()); + return InteractionPromise.resolve( + this.errorResponse("No command data found", true) + ); } const handler = this.commands.get(command.data.name); @@ -74,7 +87,8 @@ export class Bot extends REST { if (!handler) { return InteractionPromise.resolve( this.errorResponse( - `No command found with the name \`${command.data.name}\`` + `No command found with the name \`${command.data.name}\``, + true ) ); } @@ -93,7 +107,7 @@ export class Bot extends REST { }); default: return InteractionPromise.resolve( - this.errorResponse("Unhandled or unimplemented action") + this.errorResponse("Unhandled or unimplemented action", true) ); } } diff --git a/app/lib/discord/commands/helpful.ts b/app/lib/discord/commands/helpful.ts index b7e74b6..2dde627 100644 --- a/app/lib/discord/commands/helpful.ts +++ b/app/lib/discord/commands/helpful.ts @@ -91,6 +91,7 @@ export default class HelpfulCommand `${threadChannel.parent_id}, ${bot["help-channels"].size}, ${ids}}` ), ], + flags: MessageFlags.Ephemeral, }, }); } @@ -107,6 +108,7 @@ export default class HelpfulCommand embeds: [ bot.errorEmbed("This thread has already been marked as helpful!"), ], + flags: MessageFlags.Ephemeral, }); return; } @@ -137,6 +139,7 @@ export default class HelpfulCommand await bot.editReply(interaction, { content: "Your feedback has been recorded! Thank you!", + flags: MessageFlags.Ephemeral, }); } }