Fixes inproper creation of groups

This commit is contained in:
Michel Fedde 2025-05-27 20:21:59 +02:00
parent 2e26b1c210
commit 7afcd6b26a

View file

@ -108,7 +108,18 @@ export class GroupCommand implements Command, ChatInteractionCommand, Autocomple
private create(interaction: ChatInputCommandInteraction): void { private create(interaction: ChatInputCommandInteraction): void {
const name = interaction.options.getString("name") ?? ''; 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 = { const group: GroupModel = {
id: -1, id: -1,