M@
M@
DIAdiscord.js - Imagine an app
Created by M@ on 7/11/2023 in #djs-questions
Command Handler Issues
Thank you, SpecialSauce!
19 replies
DIAdiscord.js - Imagine an app
Created by M@ on 7/11/2023 in #djs-questions
Command Handler Issues
I got it!
19 replies
DIAdiscord.js - Imagine an app
Created by M@ on 7/11/2023 in #djs-questions
Command Handler Issues
That’s my main concern and take away from all of this.
19 replies
DIAdiscord.js - Imagine an app
Created by M@ on 7/11/2023 in #djs-questions
Command Handler Issues
But could I have it in a separate file from index.js? Right now I have it in a file named gpt3.5.js.
19 replies
DIAdiscord.js - Imagine an app
Created by M@ on 7/11/2023 in #djs-questions
Command Handler Issues
My OpenAI code isn’t really a command. I think a better word would be interaction or integration.
19 replies
DIAdiscord.js - Imagine an app
Created by M@ on 7/11/2023 in #djs-questions
Command Handler Issues
Could I make my command folder a slashcommands folder and make a new folder for basic commands.
19 replies
DIAdiscord.js - Imagine an app
Created by M@ on 7/11/2023 in #djs-questions
Command Handler Issues
Would I put it in my events folder?
19 replies
DIAdiscord.js - Imagine an app
Created by M@ on 7/11/2023 in #djs-questions
Command Handler Issues
Yes, I have an event handler but I don’t think any of this code interacts with my events handler.
19 replies
DIAdiscord.js - Imagine an app
Created by M@ on 7/11/2023 in #djs-questions
Command Handler Issues
[email protected] Node: v18.16.1
19 replies
DIAdiscord.js - Imagine an app
Created by M@ on 7/11/2023 in #djs-questions
Command Handler Issues
require("dotenv/config");
const { Client, IntentsBitField } = require("discord.js");
const { CommandHandler } = require("djs-commander");
const path = require("path");

const client = new Client({
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent,
],
});

new CommandHandler({
client,
commandsPath: path.join(__dirname, "commands"),
eventsPath: path.join(__dirname, "events"),
validationsPath: path.join(__dirname, "validations"),
testServer: "1027046318796963840",
});

client.login(process.env.TOKEN);
require("dotenv/config");
const { Client, IntentsBitField } = require("discord.js");
const { CommandHandler } = require("djs-commander");
const path = require("path");

const client = new Client({
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent,
],
});

new CommandHandler({
client,
commandsPath: path.join(__dirname, "commands"),
eventsPath: path.join(__dirname, "events"),
validationsPath: path.join(__dirname, "validations"),
testServer: "1027046318796963840",
});

client.login(process.env.TOKEN);
This is my index.js file, if it helps.
19 replies
DIAdiscord.js - Imagine an app
Created by M@ on 7/11/2023 in #djs-questions
Command Handler Issues
I've tried removing the .setName() and .setDescription() functions, but when I do, I'm given an error stating my command must have a name. I don't understand, because no one will ever need to read this "invisble" command. I guess it's treating it like a slash command but it's not. I just wanbt to store each of my commands in seperate files so my index.js does not get too crammed.
19 replies
DIAdiscord.js - Imagine an app
Created by M@ on 7/11/2023 in #djs-questions
Command Handler Issues
const { Configuration, OpenAIApi } = require("openai");

module.exports = {
data: new OpenAIApi(
new Configuration({
apiKey: process.env.API_KEY,
})
.setName("gpt3.5")
.setDescription("An OpenAI chatbot.")
),
run: ({ interaction }) => {
client.on("messageCreate", async (message) => {
if (message.author.bot) return;
if (message.channel.id !== process.env.CHANNEL_ID) return;
if (message.content.startsWith("!")) return;

let conversationLog = [{ role: "system", content: "You are a chatbot." }];

conversationLog.push({
role: "user",
content: message.content,
});

await message.channel.sendTyping();

const result = await openai.createChatCompletion({
model: "gpt-3.5-turbo",
messages: conversationLog,
});

message.reply(result.data.choices[0].message);
});
},
};
const { Configuration, OpenAIApi } = require("openai");

module.exports = {
data: new OpenAIApi(
new Configuration({
apiKey: process.env.API_KEY,
})
.setName("gpt3.5")
.setDescription("An OpenAI chatbot.")
),
run: ({ interaction }) => {
client.on("messageCreate", async (message) => {
if (message.author.bot) return;
if (message.channel.id !== process.env.CHANNEL_ID) return;
if (message.content.startsWith("!")) return;

let conversationLog = [{ role: "system", content: "You are a chatbot." }];

conversationLog.push({
role: "user",
content: message.content,
});

await message.channel.sendTyping();

const result = await openai.createChatCompletion({
model: "gpt-3.5-turbo",
messages: conversationLog,
});

message.reply(result.data.choices[0].message);
});
},
};
19 replies