From 7afcd6b26a379d94c6a9d25f2ff2a7b22b078934 Mon Sep 17 00:00:00 2001 From: Michel Fedde Date: Tue, 27 May 2025 20:21:59 +0200 Subject: [PATCH] Fixes inproper creation of groups --- source/Discord/Commands/Groups.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/source/Discord/Commands/Groups.ts b/source/Discord/Commands/Groups.ts index e761ccc..25be58d 100644 --- a/source/Discord/Commands/Groups.ts +++ b/source/Discord/Commands/Groups.ts @@ -108,7 +108,18 @@ export class GroupCommand implements Command, ChatInteractionCommand, Autocomple private create(interaction: ChatInputCommandInteraction): void { const name = interaction.options.getString("name") ?? ''; - const role = interaction.options.getRole("role"); + const role = interaction.options.getRole("role", true); + + if (role.id === interaction.guildId) { + throw new UserError("Creating a group for everyone is not permitted!"); + } + + if (!interaction.member?.roles.cache.has(role?.id) ?? true) { + throw new UserError( + "You are not part of the role, you try to create a group for.", + "Add yourself to the group or ask your admin to do so." + ); + } const group: GroupModel = { id: -1,