commit
This commit is contained in:
parent
4d944dd64a
commit
7cbaa32b60
3 changed files with 64 additions and 22 deletions
7
app.js
7
app.js
|
@ -219,14 +219,13 @@ bot.command('addmsg', async ctx => {
|
|||
})
|
||||
|
||||
//Discord events
|
||||
client.on('ready', () => {
|
||||
console.log(`[Discord] Logged in as ${client.user.tag} !`);
|
||||
client.user.setPresence({ activities: [{ name: 'la belle chaise', type : 3}] });
|
||||
});
|
||||
discordEvents.ready(client);
|
||||
|
||||
discordEvents.newMessage(client);
|
||||
|
||||
discordEvents.newInteraction(client);
|
||||
|
||||
discordEvents.guildCreate(client);
|
||||
|
||||
bot.launch()
|
||||
client.login(process.env.DISCORD);
|
|
@ -1,4 +1,4 @@
|
|||
const {REST , Routes, ApplicationCommandOptionType} = require('discord.js');
|
||||
const {ApplicationCommandOptionType} = require('discord.js');
|
||||
|
||||
const commands = [
|
||||
{
|
||||
|
@ -102,21 +102,11 @@ const commands = [
|
|||
name : 'github',
|
||||
description : 'Get the github link of the bot',
|
||||
},
|
||||
|
||||
{
|
||||
name : 'servers',
|
||||
description : 'Get the number of servers the bot is in',
|
||||
},
|
||||
];
|
||||
|
||||
const rest = new REST({ version: '10' }).setToken(process.env.DISCORD);
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
console.log('Started refreshing application (/) commands.');
|
||||
|
||||
await rest.put(
|
||||
Routes.applicationGuildCommands('<your discord bot ID>', '<your discord server ID>'),
|
||||
{ body: commands },
|
||||
);
|
||||
|
||||
console.log('Successfully reloaded application (/) commands.');
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
})();
|
||||
module.exports = { commands };
|
|
@ -4,6 +4,8 @@ const { addToLogs } = require('../libs/botTools');
|
|||
const { generateImage, answerQuestion, sendConv } = require('../libs/openAi');
|
||||
const { incrementQuota, addConv, delConv, getConvs, addMessage, getMessages, isNewUser } = require('../libs/mysql');
|
||||
|
||||
const { commands } = require('../commands/commands');
|
||||
|
||||
async function gptrequest(interaction) {
|
||||
await interaction.deferReply();
|
||||
|
||||
|
@ -323,6 +325,14 @@ async function github(interation) {
|
|||
console.log('[Discord] Github requested by ' + interaction.member.user.username);
|
||||
}
|
||||
|
||||
|
||||
async function servers(client) {
|
||||
console.log("Serveurs:");
|
||||
client.guilds.cache.forEach((guild) => {
|
||||
console.log(" - " + guild);
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
newMessage: (client) => {
|
||||
client.on('messageCreate', async msg => {
|
||||
|
@ -384,6 +394,49 @@ module.exports = {
|
|||
else if (interaction.commandName === 'github') {
|
||||
github(interaction);
|
||||
}
|
||||
|
||||
else if (interaction.commandName === 'servers') {
|
||||
servers(client);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
ready: (client) => {
|
||||
client.on('ready', () => {
|
||||
console.log(`[Discord] Logged in as ${client.user.tag} !`);
|
||||
client.user.setPresence({ activities: [{ name: 'la belle chaise', type: 3 }] });
|
||||
|
||||
const rest = new discord.REST({ version: '10' }).setToken(process.env.DISCORD);
|
||||
|
||||
client.guilds.cache.forEach(async (guild) => {
|
||||
try {
|
||||
await rest.put(
|
||||
discord.Routes.applicationGuildCommands('1059559067846189067', guild.id),
|
||||
{ body: commands },
|
||||
);
|
||||
|
||||
console.log('[Discord] Successfully reloaded application (/) commands for ' + guild.name + '.');
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
guildCreate: (client) => {
|
||||
client.on('guildCreate', async (guild) => {
|
||||
const rest = new discord.REST({ version: '10' }).setToken(process.env.DISCORD);
|
||||
|
||||
try {
|
||||
await rest.put(
|
||||
discord.Routes.applicationGuildCommands('1059559067846189067', guild.id),
|
||||
{ body: commands },
|
||||
);
|
||||
|
||||
console.log('[Discord] Successfully reloaded application (/) commands for ' + guild.name + '.');
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue