Skip to content

Commit

Permalink
(feat): fetch handler agent from guild_id
Browse files Browse the repository at this point in the history
  • Loading branch information
samyakkkk committed Jul 12, 2024
1 parent b94f3d5 commit 10aaae5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 141 deletions.
14 changes: 11 additions & 3 deletions discord/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require('dotenv').config();
const { Client, GatewayIntentBits, ChannelType } = require('discord.js');
// const fetch = require('node-fetch'); // Ensure you have node-fetch installed
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
Expand All @@ -11,6 +10,9 @@ const client = new Client({
]
});

// Parse the GUILD_AGENT_MAP from the environment variable
const guildAgentMap = JSON.parse(process.env.GUILD_AGENT_MAP);

client.once('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
Expand Down Expand Up @@ -90,12 +92,18 @@ client.on('messageCreate', async message => {
// await channel.send("Hold tight, I'm preparing your answer!\n\nQuick tip ⚡️, I can help you better from your IDE. Install the [VSCode extension](https://marketplace.visualstudio.com/items?itemName=WelltestedAI.fluttergpt)");
}


// Start typing indicator
const typingInterval = keepTyping(channel);

// Fetch agent details
const agentName = "flame_engine";
const guildId = message.guild.id;
const agentName = guildAgentMap[guildId];
if (!agentName) {
channel.send('Sorry, I could not find the agent for this guild.');
stopTyping(typingInterval); // Stop typing indicator
return;
}

let agentDetails;
try {
const response = await fetch("https://api.commanddash.dev/agent/get-latest-agent", {
Expand Down
138 changes: 0 additions & 138 deletions discord/x.txt

This file was deleted.

0 comments on commit 10aaae5

Please sign in to comment.