Fix rolesetup: create without empty select menu
All checks were successful
Auto Build and Push Docker Image / build (push) Successful in 7s
All checks were successful
Auto Build and Push Docker Image / build (push) Successful in 7s
This commit is contained in:
@@ -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';
|
import { Command } from '../../structures/Command.js';
|
||||||
|
|
||||||
async function updateRoleMessage(client: any, category: any) {
|
async function updateRoleMessage(client: any, category: any) {
|
||||||
@@ -152,7 +152,7 @@ const command: Command = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setTitle('📋 Rollen-Kategorien')
|
.setTitle('Rollen-Kategorien')
|
||||||
.setColor(0x3498db)
|
.setColor(0x3498db)
|
||||||
.setTimestamp();
|
.setTimestamp();
|
||||||
|
|
||||||
@@ -177,7 +177,7 @@ const command: Command = {
|
|||||||
|
|
||||||
if (subcommand === 'create') {
|
if (subcommand === 'create') {
|
||||||
if (!isAdmin) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,19 +186,12 @@ const command: Command = {
|
|||||||
|
|
||||||
const existing = DB.get('SELECT * FROM role_categories WHERE guild_id = ? AND category_name = ?', guildId, categoryName);
|
const existing = DB.get('SELECT * FROM role_categories WHERE guild_id = ? AND category_name = ?', guildId, categoryName);
|
||||||
if (existing) {
|
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;
|
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({
|
const sentMessage = await channel.send({
|
||||||
content: `**${categoryName}**\nWähle unten eine Rolle aus:`,
|
content: `**${categoryName}**\nWähle unten eine Rolle aus:\n\n*Noch keine Rollen konfiguriert. Füge Rollen mit "/rolesetup add" hinzu.*`
|
||||||
components: [row]
|
|
||||||
});
|
});
|
||||||
|
|
||||||
DB.run(
|
DB.run(
|
||||||
@@ -209,13 +202,13 @@ const command: Command = {
|
|||||||
categoryName
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subcommand === 'add') {
|
if (subcommand === 'add') {
|
||||||
if (!isAdmin) {
|
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;
|
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);
|
const category: any = DB.get('SELECT * FROM role_categories WHERE guild_id = ? AND category_name = ?', guildId, kategorie);
|
||||||
if (!category) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const existing = DB.get('SELECT * FROM role_options WHERE category_id = ? AND role_id = ?', category.id, role.id);
|
const existing = DB.get('SELECT * FROM role_options WHERE category_id = ? AND role_id = ?', category.id, role.id);
|
||||||
if (existing) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,13 +239,13 @@ const command: Command = {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await updateRoleMessage(interaction.client, category);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subcommand === 'edit') {
|
if (subcommand === 'edit') {
|
||||||
if (!isAdmin) {
|
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;
|
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);
|
const category: any = DB.get('SELECT * FROM role_categories WHERE guild_id = ? AND category_name = ?', guildId, kategorie);
|
||||||
if (!category) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const option: any = DB.get('SELECT * FROM role_options WHERE category_id = ? AND role_id = ?', category.id, oldRole.id);
|
const option: any = DB.get('SELECT * FROM role_options WHERE category_id = ? AND role_id = ?', category.id, oldRole.id);
|
||||||
if (!option) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,13 +279,13 @@ const command: Command = {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await updateRoleMessage(interaction.client, category);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subcommand === 'remove') {
|
if (subcommand === 'remove') {
|
||||||
if (!isAdmin) {
|
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;
|
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);
|
const category: any = DB.get('SELECT * FROM role_categories WHERE guild_id = ? AND category_name = ?', guildId, kategorie);
|
||||||
if (!category) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const option: any = DB.get('SELECT * FROM role_options WHERE category_id = ? AND role_id = ?', category.id, role.id);
|
const option: any = DB.get('SELECT * FROM role_options WHERE category_id = ? AND role_id = ?', category.id, role.id);
|
||||||
if (!option) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (category.remove_on_delete) {
|
if (category.remove_on_delete) {
|
||||||
const guild = interaction.guild;
|
const guild = interaction.guild;
|
||||||
const discordRole = guild.roles.cache.get(role.id);
|
const discordRole = guild.roles.cache.get(role.id);
|
||||||
if (discordRole) {
|
if (discordRole) {
|
||||||
@@ -324,13 +317,13 @@ const command: Command = {
|
|||||||
|
|
||||||
DB.run('DELETE FROM role_options WHERE id = ?', option.id);
|
DB.run('DELETE FROM role_options WHERE id = ?', option.id);
|
||||||
await updateRoleMessage(interaction.client, category);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subcommand === 'delete') {
|
if (subcommand === 'delete') {
|
||||||
if (!isAdmin) {
|
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;
|
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);
|
const category: any = DB.get('SELECT * FROM role_categories WHERE guild_id = ? AND category_name = ?', guildId, kategorie);
|
||||||
if (!category) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,13 +359,13 @@ const command: Command = {
|
|||||||
|
|
||||||
DB.run('DELETE FROM role_categories WHERE id = ?', category.id);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subcommand === 'config') {
|
if (subcommand === 'config') {
|
||||||
if (!isAdmin) {
|
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;
|
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);
|
const category: any = DB.get('SELECT * FROM role_categories WHERE guild_id = ? AND category_name = ?', guildId, kategorie);
|
||||||
if (!category) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,11 +395,11 @@ const command: Command = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (updates.length === 0) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await interaction.reply({ content: `✅ Konfiguration aktualisiert: ${updates.join(', ')}`, flags: [MessageFlags.Ephemeral] });
|
await interaction.reply({ content: `Konfiguration aktualisiert: ${updates.join(', ')}`, flags: [MessageFlags.Ephemeral] });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user