Fix rolesetup: create without empty select menu
All checks were successful
Auto Build and Push Docker Image / build (push) Successful in 7s

This commit is contained in:
2026-04-03 06:20:43 +00:00
parent ad988c9333
commit 14781b8e52

View File

@@ -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,13 +294,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, 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;
}
@@ -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] });
}
}
};