Compare commits
No commits in common. "513244f203e5de360a8756bab6706f507fe37e5e" and "6eda872b08759e0d551a47ea6103ce563edd6ce9" have entirely different histories.
513244f203
...
6eda872b08
4 changed files with 6 additions and 71 deletions
|
@ -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,
|
|
||||||
});
|
|
||||||
};
|
|
|
@ -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.`);
|
|
||||||
},
|
|
||||||
};
|
|
17
src/index.js
17
src/index.js
|
@ -1,6 +1,5 @@
|
||||||
import loadClient from './utils/client.js';
|
import loadClient from './utils/client.js';
|
||||||
import loadEvents from './events/loader.js';
|
import loadEvents from './events/loader.js';
|
||||||
import loadCommands from './commands/loader.js';
|
|
||||||
|
|
||||||
const run = async () => {
|
const run = async () => {
|
||||||
console.log('Starting Botanique...');
|
console.log('Starting Botanique...');
|
||||||
|
@ -15,25 +14,19 @@ const run = async () => {
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
throw 'Client ❌';
|
throw 'Client ❌';
|
||||||
});
|
});
|
||||||
if (client) {
|
console.log('Client ✅');
|
||||||
console.log('Client ✅');
|
|
||||||
}
|
|
||||||
|
|
||||||
await loadEvents(client)
|
await loadEvents(client)
|
||||||
.then(console.log('Events ✅'))
|
.then(() => console.log('Events ✅'))
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
throw 'Events ❌';
|
throw 'Events ❌';
|
||||||
});
|
});
|
||||||
|
|
||||||
await client.login(client.config.token_discord);
|
await client.login(client.config.token_discord);
|
||||||
|
|
||||||
await loadCommands(client)
|
console.log(
|
||||||
.then(console.log('Commands ✅'))
|
`Botanique "${client.user.username}" ${client.config.version} started!`
|
||||||
.catch(() => {
|
);
|
||||||
throw 'Commands ❌';
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log(`Botanique "${client.user.username}" ${client.config.version} started!`);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
run().catch(error => console.error(error));
|
run().catch(error => console.error(error));
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Client, Collection, Intents } from 'discord.js';
|
import { Client, Intents } from 'discord.js';
|
||||||
import { readFileSync } from 'fs';
|
import { readFileSync } from 'fs';
|
||||||
|
|
||||||
const { version } = JSON.parse(readFileSync('./package.json'));
|
const { version } = JSON.parse(readFileSync('./package.json'));
|
||||||
|
@ -11,14 +11,10 @@ export default async () => {
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
// Store the client configuration
|
|
||||||
client.config = {
|
client.config = {
|
||||||
version: version,
|
version: version,
|
||||||
token_discord: process.env.TOKEN_DISCORD,
|
token_discord: process.env.TOKEN_DISCORD,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Store the commands available
|
|
||||||
client.commands = new Collection();
|
|
||||||
|
|
||||||
return client;
|
return client;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue