#api for bdfd

32 messages · Page 1 of 1 (latest)

red patio
#

Is there a api link to use it in bdfd like this ? To chat with openai?

fervent sand
#

No, since there is no official api out yet

midnight sonnet
#

Their is API keys that you can use, these can most likely be implemented into your code, this depends upon what you’re trying to do though. I’m not to up to date on it yet.

midnight sonnet
red patio
#

Yes bud how is the question 🤧

midnight sonnet
red patio
#

I try to build chatgpt in my discord bot like a chatbot

midnight sonnet
#

Oh okay

#

I did that a few days ago

red patio
#

It stil works?

midnight sonnet
#

Or almost did, until chatbot went caput

midnight sonnet
red patio
#

I find a method in replit bud it didnt work

midnight sonnet
#

Hm

#

The method i was using involves using the api key found on the website

#

I'll see if i can figure it out again later

red patio
#

Api key on the website istelf or you did get it from chrome dev?

midnight sonnet
#

Website itself

#

So that's why im unsure if it was ever going to work

#

I stopped as i was implementing everything, since the website crashed and i was confused on one thing.

#

I'll test it out later and if it works i'll send the info here or dms

red patio
#

I tryed thisone bud it didnt work for me

midnight sonnet
#

oh okay

#

I am talking about creating it from scratch

#

If those api keys are working how i assume they are then it should all work out. If so im going to create a chrome developer extension where you click the extension and you can ask and recieve responses from the bot in the little text square in the top of your screen and then it will have a scan page button etc. But I won't get my hopes up, I'll message you back either later or tommorow.

red patio
#

I did try that it didnt work for me hehe

#

Bud thanx i wil see you tomorow

#

🤲

midnight sonnet
midnight sonnet
#

@red patio

#

const OpenAI = require('openai');
const { Constants } = require('discord.js');
const Intents = Constants.Intents;

// Replace these values with your own Discord and OpenAI API keys
const discordToken = process.env.DISCORD_TOKEN;
const openaiKey = process.env.OPENAI_KEY;

// Set the intents property in the client options
// In this example, we will enable the GUILD_PRESENCES and GUILD_MEMBERS intents
const options = {
intents: Intents.FLAGS.GUILD_PRESENCES | Intents.FLAGS.GUILD_MEMBERS
};

// Create a new Discord client
const client = new Discord.Client(options);

// Configure OpenAI client
OpenAI.apiKey = openaiKey;

// This event will run when the bot is ready to start working
client.on('ready', () => {
console.log(Logged in as ${client.user.tag}!);
});

// This event will run when the bot receives a message
client.on('message', async message => {
// Ignore messages that are sent by the bot itself
if (message.author.bot) return;

// Check if the message starts with /ai
if (message.content.startsWith('/ai')) {
// Get the text after /ai and send it to chat.openai.com
const query = message.content.replace('/ai', '');

// Send the query to OpenAI and get the response
const response = await OpenAI.query(query);

// Send the response to the Discord channel
message.channel.send(response.data.replies);

}
});

// Log the bot in
client.login(discordToken);