Compare commits

..

No commits in common. "513244f203e5de360a8756bab6706f507fe37e5e" and "6eda872b08759e0d551a47ea6103ce563edd6ce9" have entirely different histories.

4 changed files with 6 additions and 71 deletions

View file

@ -1,37 +0,0 @@
import { REST } from '@discordjs/rest';
import { Routes } from 'discord-api-types/v9';
import { readdir } from 'fs/promises';
export default async client => {
const rest = new REST({ version: '9' }).setToken(client.token);
const command_categories = (await readdir('./src/commands'))
.filter(element => !element.endsWith('.js'));
const commands = (
await Promise.all(
// For each categorie
command_categories.map(async command_category => {
// Retrieve all the commands
const command_files = await readdir(`./src/commands/${command_category}`);
// Add the command
return Promise.all(
command_files.map(async command_file => {
const command = (
await import(`../commands/${command_category}/${command_file}`)
).default;
client.commands.set(command.data.name, command);
return command.data.toJSON();
}),
);
}),
)
).flat(2);
return await rest.put(Routes.applicationCommands(client.user.id), {
body: commands,
});
};

View file

@ -1,17 +0,0 @@
import { SlashCommandBuilder } from '@discordjs/builders';
export default {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Pong!'),
interaction: async (interaction, client) => {
const sent = await interaction.reply({ content: 'Pinging...', fetchReply: true });
interaction.editReply(
`Roundtrip latency:
${sent.createdTimestamp - interaction.createdTimestamp}ms
Websocket heartbeat: ${client.ws.ping}ms.`);
},
};

View file

@ -1,6 +1,5 @@
import loadClient from './utils/client.js';
import loadEvents from './events/loader.js';
import loadCommands from './commands/loader.js';
const run = async () => {
console.log('Starting Botanique...');
@ -15,25 +14,19 @@ const run = async () => {
.catch(() => {
throw 'Client ❌';
});
if (client) {
console.log('Client ✅');
}
await loadEvents(client)
.then(console.log('Events ✅'))
.then(() => console.log('Events ✅'))
.catch(() => {
throw 'Events ❌';
});
await client.login(client.config.token_discord);
await loadCommands(client)
.then(console.log('Commands ✅'))
.catch(() => {
throw 'Commands ❌';
});
console.log(`Botanique "${client.user.username}" ${client.config.version} started!`);
console.log(
`Botanique "${client.user.username}" ${client.config.version} started!`
);
};
run().catch(error => console.error(error));

View file

@ -1,4 +1,4 @@
import { Client, Collection, Intents } from 'discord.js';
import { Client, Intents } from 'discord.js';
import { readFileSync } from 'fs';
const { version } = JSON.parse(readFileSync('./package.json'));
@ -11,14 +11,10 @@ export default async () => {
],
});
// Store the client configuration
client.config = {
version: version,
token_discord: process.env.TOKEN_DISCORD,
};
// Store the commands available
client.commands = new Collection();
return client;
};