From 16031cc5452be00267623a48137e33d29448925f Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Sat, 8 Nov 2025 10:42:53 +0000 Subject: [PATCH] Create /set-realm command to choose primary arm cgen-8e17e4dbfb8f48cda68f152b6cef8299 --- discord-bot/commands/set-realm.js | 95 +++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 discord-bot/commands/set-realm.js diff --git a/discord-bot/commands/set-realm.js b/discord-bot/commands/set-realm.js new file mode 100644 index 00000000..787eefc9 --- /dev/null +++ b/discord-bot/commands/set-realm.js @@ -0,0 +1,95 @@ +const { SlashCommandBuilder, EmbedBuilder, StringSelectMenuBuilder, ActionRowBuilder } = require('discord.js'); + +const REALMS = [ + { value: 'labs', label: '๐Ÿงช Labs', description: 'Research & Development' }, + { value: 'gameforge', label: '๐ŸŽฎ GameForge', description: 'Game Development' }, + { value: 'corp', label: '๐Ÿ’ผ Corp', description: 'Enterprise Solutions' }, + { value: 'foundation', label: '๐Ÿค Foundation', description: 'Community & Education' }, + { value: 'devlink', label: '๐Ÿ’ป Dev-Link', description: 'Professional Networking' }, +]; + +module.exports = { + data: new SlashCommandBuilder() + .setName('set-realm') + .setDescription('Set your primary AeThex realm/arm'), + + async execute(interaction, supabase) { + await interaction.deferReply({ ephemeral: true }); + + try { + const { data: link } = await supabase + .from('discord_links') + .select('user_id, primary_arm') + .eq('discord_id', interaction.user.id) + .single(); + + if (!link) { + const embed = new EmbedBuilder() + .setColor(0xFF6B6B) + .setTitle('โŒ Not Linked') + .setDescription('You must link your Discord account to AeThex first.\nUse `/verify` to get started.'); + + return await interaction.editReply({ embeds: [embed] }); + } + + const select = new StringSelectMenuBuilder() + .setCustomId('select_realm') + .setPlaceholder('Choose your primary realm') + .addOptions( + REALMS.map(realm => ({ + label: realm.label, + description: realm.description, + value: realm.value, + default: realm.value === link.primary_arm, + })), + ); + + const row = new ActionRowBuilder().addComponents(select); + + const embed = new EmbedBuilder() + .setColor(0x7289DA) + .setTitle('โš”๏ธ Choose Your Realm') + .setDescription('Select your primary AeThex realm. This determines your main Discord role.') + .addFields( + { name: 'Current Realm', value: link.primary_arm || 'Not set' }, + ); + + await interaction.editReply({ embeds: [embed], components: [row] }); + + const filter = i => i.user.id === interaction.user.id && i.customId === 'select_realm'; + const collector = interaction.channel.createMessageComponentCollector({ filter, time: 60000 }); + + collector.on('collect', async i => { + const selectedRealm = i.values[0]; + + await supabase + .from('discord_links') + .update({ primary_arm: selectedRealm }) + .eq('discord_id', interaction.user.id); + + const realm = REALMS.find(r => r.value === selectedRealm); + + const confirmEmbed = new EmbedBuilder() + .setColor(0x00FF00) + .setTitle('โœ… Realm Set') + .setDescription(`Your primary realm is now **${realm.label}**\n\nYou'll be assigned the corresponding Discord role.`); + + await i.update({ embeds: [confirmEmbed], components: [] }); + }); + + collector.on('end', collected => { + if (collected.size === 0) { + interaction.editReply({ content: 'Realm selection timed out.', components: [] }); + } + }); + } catch (error) { + console.error('Set-realm command error:', error); + const embed = new EmbedBuilder() + .setColor(0xFF0000) + .setTitle('โŒ Error') + .setDescription('Failed to update realm. Please try again.'); + + await interaction.editReply({ embeds: [embed] }); + } + }, +};