From 14781b8e52c9adac00cdccbb269ebc9fc113a334 Mon Sep 17 00:00:00 2001 From: coding Date: Fri, 3 Apr 2026 06:20:43 +0000 Subject: [PATCH] Fix rolesetup: create without empty select menu --- src/commands/utility/rolesetup.ts | 59 ++++++++++++++----------------- 1 file changed, 26 insertions(+), 33 deletions(-) diff --git a/src/commands/utility/rolesetup.ts b/src/commands/utility/rolesetup.ts index 312b4c1..c834477 100644 --- a/src/commands/utility/rolesetup.ts +++ b/src/commands/utility/rolesetup.ts @@ -1,4 +1,4 @@ -import { SlashCommandBuilder, PermissionFlagsBits, EmbedBuilder, MessageFlags, ChannelType, ComponentType, StringSelectMenuBuilder, StringSelectMenuOptionBuilder, GuildMember } from 'discord.js'; +import { SlashCommandBuilder, PermissionFlagsBits, EmbedBuilder, MessageFlags, ChannelType, ComponentType, StringSelectMenuBuilder, StringSelectMenuOptionBuilder } from 'discord.js'; import { Command } from '../../structures/Command.js'; async function updateRoleMessage(client: any, category: any) { @@ -152,7 +152,7 @@ const command: Command = { } const embed = new EmbedBuilder() - .setTitle('📋 Rollen-Kategorien') + .setTitle('Rollen-Kategorien') .setColor(0x3498db) .setTimestamp(); @@ -177,7 +177,7 @@ const command: Command = { if (subcommand === 'create') { if (!isAdmin) { - await interaction.reply({ content: '❌ Keine Berechtigung. Moderatoren erforderlich.', flags: [MessageFlags.Ephemeral] }); + await interaction.reply({ content: 'Keine Berechtigung. Moderatoren erforderlich.', flags: [MessageFlags.Ephemeral] }); return; } @@ -186,19 +186,12 @@ const command: Command = { const existing = DB.get('SELECT * FROM role_categories WHERE guild_id = ? AND category_name = ?', guildId, categoryName); if (existing) { - await interaction.reply({ content: `❌ Kategorie "${categoryName}" existiert bereits.`, flags: [MessageFlags.Ephemeral] }); + await interaction.reply({ content: `Kategorie "${categoryName}" existiert bereits.`, flags: [MessageFlags.Ephemeral] }); return; } - const selectMenu = new StringSelectMenuBuilder() - .setCustomId(`role_select_${categoryName}`) - .setPlaceholder('Wähle eine Rolle...'); - - const row = { type: ComponentType.ActionRow, components: [selectMenu] }; - const sentMessage = await channel.send({ - content: `**${categoryName}**\nWähle unten eine Rolle aus:`, - components: [row] + content: `**${categoryName}**\nWähle unten eine Rolle aus:\n\n*Noch keine Rollen konfiguriert. Füge Rollen mit "/rolesetup add" hinzu.*` }); DB.run( @@ -209,13 +202,13 @@ const command: Command = { categoryName ); - await interaction.reply({ content: `✅ Kategorie "${categoryName}" erstellt in ${channel}.`, flags: [MessageFlags.Ephemeral] }); + await interaction.reply({ content: `Kategorie "${categoryName}" erstellt in ${channel}.`, flags: [MessageFlags.Ephemeral] }); return; } if (subcommand === 'add') { if (!isAdmin) { - await interaction.reply({ content: '❌ Keine Berechtigung. Moderatoren erforderlich.', flags: [MessageFlags.Ephemeral] }); + await interaction.reply({ content: 'Keine Berechtigung. Moderatoren erforderlich.', flags: [MessageFlags.Ephemeral] }); return; } @@ -225,13 +218,13 @@ const command: Command = { const category: any = DB.get('SELECT * FROM role_categories WHERE guild_id = ? AND category_name = ?', guildId, kategorie); if (!category) { - await interaction.reply({ content: `❌ Kategorie "${kategorie}" nicht gefunden.`, flags: [MessageFlags.Ephemeral] }); + await interaction.reply({ content: `Kategorie "${kategorie}" nicht gefunden.`, flags: [MessageFlags.Ephemeral] }); return; } const existing = DB.get('SELECT * FROM role_options WHERE category_id = ? AND role_id = ?', category.id, role.id); if (existing) { - await interaction.reply({ content: `❌ Rolle ${role.name} ist bereits in "${kategorie}".`, flags: [MessageFlags.Ephemeral] }); + await interaction.reply({ content: `Rolle ${role.name} ist bereits in "${kategorie}".`, flags: [MessageFlags.Ephemeral] }); return; } @@ -246,13 +239,13 @@ const command: Command = { ); await updateRoleMessage(interaction.client, category); - await interaction.reply({ content: `✅ ${role.name} zu "${kategorie}" hinzugefügt.`, flags: [MessageFlags.Ephemeral] }); + await interaction.reply({ content: `${role.name} zu "${kategorie}" hinzugefügt.`, flags: [MessageFlags.Ephemeral] }); return; } if (subcommand === 'edit') { if (!isAdmin) { - await interaction.reply({ content: '❌ Keine Berechtigung. Moderatoren erforderlich.', flags: [MessageFlags.Ephemeral] }); + await interaction.reply({ content: 'Keine Berechtigung. Moderatoren erforderlich.', flags: [MessageFlags.Ephemeral] }); return; } @@ -263,13 +256,13 @@ const command: Command = { const category: any = DB.get('SELECT * FROM role_categories WHERE guild_id = ? AND category_name = ?', guildId, kategorie); if (!category) { - await interaction.reply({ content: `❌ Kategorie "${kategorie}" nicht gefunden.`, flags: [MessageFlags.Ephemeral] }); + await interaction.reply({ content: `Kategorie "${kategorie}" nicht gefunden.`, flags: [MessageFlags.Ephemeral] }); return; } const option: any = DB.get('SELECT * FROM role_options WHERE category_id = ? AND role_id = ?', category.id, oldRole.id); if (!option) { - await interaction.reply({ content: `❌ Rolle ${oldRole.name} ist nicht in "${kategorie}".`, flags: [MessageFlags.Ephemeral] }); + await interaction.reply({ content: `Rolle ${oldRole.name} ist nicht in "${kategorie}".`, flags: [MessageFlags.Ephemeral] }); return; } @@ -286,13 +279,13 @@ const command: Command = { ); await updateRoleMessage(interaction.client, category); - await interaction.reply({ content: `✅ Option in "${kategorie}" aktualisiert.`, flags: [MessageFlags.Ephemeral] }); + await interaction.reply({ content: `Option in "${kategorie}" aktualisiert.`, flags: [MessageFlags.Ephemeral] }); return; } if (subcommand === 'remove') { if (!isAdmin) { - await interaction.reply({ content: '❌ Keine Berechtigung. Moderatoren erforderlich.', flags: [MessageFlags.Ephemeral] }); + await interaction.reply({ content: 'Keine Berechtigung. Moderatoren erforderlich.', flags: [MessageFlags.Ephemeral] }); return; } @@ -301,17 +294,17 @@ const command: Command = { const category: any = DB.get('SELECT * FROM role_categories WHERE guild_id = ? AND category_name = ?', guildId, kategorie); if (!category) { - await interaction.reply({ content: `❌ Kategorie "${kategorie}" nicht gefunden.`, flags: [MessageFlags.Ephemeral] }); + await interaction.reply({ content: `Kategorie "${kategorie}" nicht gefunden.`, flags: [MessageFlags.Ephemeral] }); return; } const option: any = DB.get('SELECT * FROM role_options WHERE category_id = ? AND role_id = ?', category.id, role.id); if (!option) { - await interaction.reply({ content: `❌ Rolle ${role.name} ist nicht in "${kategorie}".`, flags: [MessageFlags.Ephemeral] }); + await interaction.reply({ content: `Rolle ${role.name} ist nicht in "${kategorie}".`, flags: [MessageFlags.Ephemeral] }); return; } - if (category.remove_on_delete) { + if (category.remove_on_delete) { const guild = interaction.guild; const discordRole = guild.roles.cache.get(role.id); if (discordRole) { @@ -324,13 +317,13 @@ const command: Command = { DB.run('DELETE FROM role_options WHERE id = ?', option.id); await updateRoleMessage(interaction.client, category); - await interaction.reply({ content: `✅ ${role.name} aus "${kategorie}" entfernt.`, flags: [MessageFlags.Ephemeral] }); + await interaction.reply({ content: `${role.name} aus "${kategorie}" entfernt.`, flags: [MessageFlags.Ephemeral] }); return; } if (subcommand === 'delete') { if (!isAdmin) { - await interaction.reply({ content: '❌ Keine Berechtigung. Moderatoren erforderlich.', flags: [MessageFlags.Ephemeral] }); + await interaction.reply({ content: 'Keine Berechtigung. Moderatoren erforderlich.', flags: [MessageFlags.Ephemeral] }); return; } @@ -338,7 +331,7 @@ const command: Command = { const category: any = DB.get('SELECT * FROM role_categories WHERE guild_id = ? AND category_name = ?', guildId, kategorie); if (!category) { - await interaction.reply({ content: `❌ Kategorie "${kategorie}" nicht gefunden.`, flags: [MessageFlags.Ephemeral] }); + await interaction.reply({ content: `Kategorie "${kategorie}" nicht gefunden.`, flags: [MessageFlags.Ephemeral] }); return; } @@ -366,13 +359,13 @@ const command: Command = { DB.run('DELETE FROM role_categories WHERE id = ?', category.id); - await interaction.reply({ content: `✅ Kategorie "${kategorie}" gelöscht.`, flags: [MessageFlags.Ephemeral] }); + await interaction.reply({ content: `Kategorie "${kategorie}" geloescht.`, flags: [MessageFlags.Ephemeral] }); return; } if (subcommand === 'config') { if (!isAdmin) { - await interaction.reply({ content: '❌ Keine Berechtigung. Moderatoren erforderlich.', flags: [MessageFlags.Ephemeral] }); + await interaction.reply({ content: 'Keine Berechtigung. Moderatoren erforderlich.', flags: [MessageFlags.Ephemeral] }); return; } @@ -383,7 +376,7 @@ const command: Command = { const category: any = DB.get('SELECT * FROM role_categories WHERE guild_id = ? AND category_name = ?', guildId, kategorie); if (!category) { - await interaction.reply({ content: `❌ Kategorie "${kategorie}" nicht gefunden.`, flags: [MessageFlags.Ephemeral] }); + await interaction.reply({ content: `Kategorie "${kategorie}" nicht gefunden.`, flags: [MessageFlags.Ephemeral] }); return; } @@ -402,11 +395,11 @@ const command: Command = { } if (updates.length === 0) { - await interaction.reply({ content: 'Keine Änderungen angegeben.', flags: [MessageFlags.Ephemeral] }); + await interaction.reply({ content: 'Keine Aenderungen angegeben.', flags: [MessageFlags.Ephemeral] }); return; } - await interaction.reply({ content: `✅ Konfiguration aktualisiert: ${updates.join(', ')}`, flags: [MessageFlags.Ephemeral] }); + await interaction.reply({ content: `Konfiguration aktualisiert: ${updates.join(', ')}`, flags: [MessageFlags.Ephemeral] }); } } };