diff options
| author | Alex Pooley (@zuedev) <zuedev@gmail.com> | 2026-07-22 15:32:57 +0100 |
|---|---|---|
| committer | Alex Pooley (@zuedev) <zuedev@gmail.com> | 2026-07-22 15:32:57 +0100 |
| commit | 72487019b3f255cece40a8073bbad8bc9968a3b7 (patch) | |
| tree | b6590e63039cdc8b1820bd345cdfe83f28ff839b /174bg/discord-bot/source/commands/uex.js | |
| parent | da0509c91376f56f133872eddd2e4282d76f215e (diff) | |
| download | unnamed-group-72487019b3f255cece40a8073bbad8bc9968a3b7.tar unnamed-group-72487019b3f255cece40a8073bbad8bc9968a3b7.tar.gz unnamed-group-72487019b3f255cece40a8073bbad8bc9968a3b7.tar.bz2 unnamed-group-72487019b3f255cece40a8073bbad8bc9968a3b7.tar.xz unnamed-group-72487019b3f255cece40a8073bbad8bc9968a3b7.zip | |
major code refactor, add uex lookup
Diffstat (limited to '174bg/discord-bot/source/commands/uex.js')
| -rw-r--r-- | 174bg/discord-bot/source/commands/uex.js | 81 |
1 files changed, 81 insertions, 0 deletions
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 |
