This commit is contained in:
Lukian 2023-07-06 20:53:10 +02:00
parent 4dcd4c9072
commit 0163d40b4e
3 changed files with 63 additions and 2 deletions

View file

@ -141,6 +141,11 @@ const commands = [
},
],
},
{
name : 'help',
description : 'Get help',
},
];
module.exports = { commands };

View file

@ -14,6 +14,7 @@ const github = require('../functions/discord/github');
const dalle = require('../functions/discord/dalle');
const addchannel = require('../functions/discord/addchannel');
const deletechannel = require('../functions/discord/deletechannel');
const help = require('../functions/discord/help');
const { listchannels, incrementQuota, isNewUser } = require('../libs/mysql');
const { sendQuickConv } = require('../libs/openAi')
@ -119,6 +120,10 @@ module.exports = {
else if (interaction.commandName === 'deletechannel') {
deletechannel(interaction, client);
}
else if (interaction.commandName === 'help') {
help(interaction, client);
}
});
},
@ -126,8 +131,6 @@ module.exports = {
client.on('ready', async () => {
console.log(`[Discord] Logged in as ${client.user.tag} !`);
client.user.setPresence({ activities: [{ name: client.guilds.cache.size + ' servers !', type: 3 }] });
const rest = new discord.REST({ version: '10' }).setToken(process.env.DISCORD);
await rest.put(
@ -136,6 +139,21 @@ module.exports = {
);
console.log('[Discord] Successfully reloaded application (/) commands globally.');
client.user.setPresence({ activities: [{ name: client.guilds.cache.size + ' servers !', type: 3 }] });
n = 1;
act = [
[{ name: client.guilds.cache.size + ' servers !', type: 3 }],
[{ name: '/help command', type: 3 }],
];
setInterval(() => {
client.user.setPresence({ activities: act[n] });
if (n == 1) { n = 0; }
else { n = 1; }
}, 10000);
});
},
}

38
functions/discord/help.js Normal file
View file

@ -0,0 +1,38 @@
const { EmbedBuilder } = require('discord.js');
function help(interaction, client) {
const embed = new EmbedBuilder()
.setColor(0xFABBDE)
.setAuthor({ name: "Help", iconURL: client.user.displayAvatarURL() })
.setDescription(`
**OpenAI basic commands :**
\`/gptrequest [query]\` : Make a request to the GPT-4 API
\`/quickgpt [query]\` : Make a request to the GPT-3.5-turbo API
\`/dalle [query]\` : Make a request to the DALL-E API
**OpenAI conversations commands :**
*Note : These commands allow you to create conversations and add messages to them, so that the bot will remember your previous messages*
\`/addconv [convName]\` : Add a conversation to the database
\`/delconv [convName]\` : Delete a conversation from the database
\`/listconvs\` : List all the conversations in the database
\`/displayconv [convName]\` : Display a conversation from the database
\`/addmsg [message]\` : Add a message to the conversation
**Channel commands :**
*Note : These commands allow you to talk to the bots without using any commands in a specific channel (this requires admin permission)*
\`/addchannel [channelName]\` : Add a channel to the database
\`/delchannel [channelName]\` : Delete a channel from the database
**Miscellaneous commands :**
\`/github\` : Get the github link of the bot
\`/getmyquota\` : Get your quota *Note : Since the OpenAI API is not free, all users have a quota of 200k tokens*
\`/help\` : Display this message
`)
.setFooter({ text: "Powered by OpenAI https://www.openai.com/", iconURL: "https://seeklogo.com/images/O/open-ai-logo-8B9BFEDC26-seeklogo.com.png" });
interaction.reply({ embeds: [embed] });
}
module.exports = help;