From 72487019b3f255cece40a8073bbad8bc9968a3b7 Mon Sep 17 00:00:00 2001 From: "Alex Pooley (@zuedev)" Date: Wed, 22 Jul 2026 15:32:57 +0100 Subject: major code refactor, add uex lookup --- 174bg/discord-bot/source/commands/uex.js | 81 ++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 174bg/discord-bot/source/commands/uex.js (limited to '174bg/discord-bot/source/commands/uex.js') diff --git a/174bg/discord-bot/source/commands/uex.js b/174bg/discord-bot/source/commands/uex.js new file mode 100644 index 0000000..f2f654f --- /dev/null +++ b/174bg/discord-bot/source/commands/uex.js @@ -0,0 +1,81 @@ +import { SlashCommandBuilder, MessageFlags } from "discord.js"; +import { items } from "../controllers/uex.js"; + +export default { + data: new SlashCommandBuilder() + .setName("uex") + .setDescription( + "Commands for interacting with UEX.", + ) + .addSubcommandGroup((subcommandGroup) => + subcommandGroup + .setName("lookup") + .setDescription("Lookup UEX information.") + .addSubcommand((subcommand) => + subcommand + .setName("items") + .setDescription("Perform UEX lookup for Star Citizen items, including ship components, weapons, and more.") + .addStringOption((option) => + option + .setName("query") + .setDescription( + "The item name or partial name to search for.", + ) + .setRequired(true), + ), + ) + ), + execute: async (interaction) => { + const subcommandGroup = interaction.options.getSubcommandGroup(); + const subcommand = interaction.options.getSubcommand(); + + switch (subcommandGroup) { + case "lookup": + switch (subcommand) { + case "items": + await uex_lookup_items(interaction); + break; + default: + await interaction.reply({ + content: "Unknown subcommand.", + ephemeral: true, + }); + break; + } + break; + default: + await interaction.reply({ + content: "Unknown subcommand group.", + ephemeral: true, + }); + break; + } + }, +}; + +async function uex_lookup_items(interaction) { + const query = interaction.options.getString("query"); + + await interaction.deferReply({ flags: MessageFlags.Ephemeral }); + + const allItems = await items(); + + const matchingItems = allItems.filter((item) => + item.name.toLowerCase().includes(query.toLowerCase()), + ); + + if (matchingItems.length === 0) { + await interaction.editReply({ + content: `No items found matching "${query}".`, + }); + return; + } + + const itemList = matchingItems + .map((item) => `- ${item.name} (ID: ${item.id})`) + .join("\n"); + + await interaction.editReply({ + content: `Found ${matchingItems.length} item(s) matching "${query}":\n${itemList}`, + }); +} \ No newline at end of file -- cgit v1.2.3