From 5420995159946e7e11fdf861974132bd590a2fbf Mon Sep 17 00:00:00 2001 From: "Alex Pooley (@zuedev)" Date: Wed, 15 Jul 2026 12:09:43 +0100 Subject: add gemini check to req tickets --- 174bg/discord-bot/main.js | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) (limited to '174bg/discord-bot/main.js') diff --git a/174bg/discord-bot/main.js b/174bg/discord-bot/main.js index cbbdebf..c87f6b3 100644 --- a/174bg/discord-bot/main.js +++ b/174bg/discord-bot/main.js @@ -11,6 +11,10 @@ import { ButtonStyle, } from "discord.js"; +import {GoogleGenAI} from '@google/genai'; + +const ai = new GoogleGenAI({apiKey: process.env.GEMINI_API_KEY}); + const commands = [ { data: new SlashCommandBuilder() @@ -53,12 +57,20 @@ const commands = [ return await interaction.reply("Tickets category not found."); // get the quartermaster role id - const quartermasterRole = interaction.guild.roles.cache.find( + let quartermasterRole = interaction.guild.roles.cache.find( (role) => role.name.toLowerCase() === "quartermaster", ); if (!quartermasterRole) - return await interaction.reply("Quartermaster role not found."); + { + // no qm role? make it + const newRole = await interaction.guild.roles.create({ + name: "Quartermaster", + color: "Blue", + }); + + quartermasterRole = newRole; + } // create a new text channel under the "tickets" category with the following format: // req- @@ -116,7 +128,7 @@ const commands = [ `Requisition ticket <#${newChannel.id}> created by <@${interaction.user.id}>`, ); - // notify all members with the quartermaster role + // notify all members with the quartermaster role if it exists // fetch guild members so the cache (and role.members) reflects the latest state await interaction.guild.members.fetch(); const quartermasterMembers = quartermasterRole.members; @@ -125,6 +137,29 @@ const commands = [ `A new requisition ticket has been created: <#${newChannel.id}>`, ); } + + // use gemini to lookup where we can get the contents + const prompt = ` + Where can I get the following stuff in Star Citizen? + + \`\`\` + ${contents} + \`\`\` + + Respond in the following format: + + \`\`\` + - Item Name: Location + ... + \`\`\` + + Do not include anything else except the format. + `; + const response = await ai.models.generateContent({ + model: "gemini-3.5-flash", + contents: prompt, + }); + await newChannel.send(`## AI Suggestion\n\n>>> ${response.text}`); }, }, { -- cgit v1.2.3