Compare commits
No commits in common. "5fa03d8097a7b767493ae2673a71332a25d50d44" and "721e7dfc87f1c22a47a1523d658ccd55faeb3a19" have entirely different histories.
5fa03d8097
...
721e7dfc87
3 changed files with 10 additions and 11 deletions
|
@ -4,8 +4,8 @@
|
||||||
"description": "Bot discord",
|
"description": "Bot discord",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"main": "npx tsc && node ./dist/index.js",
|
"main": "tsc && node ./dist/index.js",
|
||||||
"debug": "npx tsnd --respawn ./src/index.ts",
|
"debug": "tsnd --respawn ./src/index.ts",
|
||||||
"lint": "npx eslint src"
|
"lint": "npx eslint src"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
@ -6,15 +6,15 @@ import { readdir } from 'fs/promises';
|
||||||
export default async (client: Client) => {
|
export default async (client: Client) => {
|
||||||
const rest = new REST({ version: '9' }).setToken(client.token ?? '');
|
const rest = new REST({ version: '9' }).setToken(client.token ?? '');
|
||||||
|
|
||||||
const command_categories = (await readdir(__dirname))
|
const command_categories = (await readdir('./src/commands'))
|
||||||
.filter(element => !element.endsWith('.js') && !element.endsWith('.ts'));
|
.filter(element => !element.endsWith('.ts'));
|
||||||
|
|
||||||
const commands = (
|
const commands = (
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
// For each categorie
|
// For each categorie
|
||||||
command_categories.map(async command_category => {
|
command_categories.map(async command_category => {
|
||||||
// Retrieve all the commands
|
// Retrieve all the commands
|
||||||
const command_files = await readdir(`${__dirname}/${command_category}`);
|
const command_files = await readdir(`./src/commands/${command_category}`);
|
||||||
|
|
||||||
// Add the command
|
// Add the command
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
|
|
|
@ -2,12 +2,12 @@ import { Client } from 'discord.js';
|
||||||
import { readdir } from 'fs/promises';
|
import { readdir } from 'fs/promises';
|
||||||
|
|
||||||
export default async (client: Client) => {
|
export default async (client: Client) => {
|
||||||
const events_categories = (await readdir(__dirname))
|
const events_categories = (await readdir('./src/events'))
|
||||||
.filter(element => !element.endsWith('.js') && !element.endsWith('.ts'));
|
.filter(element => !element.endsWith('.ts'));
|
||||||
|
|
||||||
events_categories.forEach(async event_category => {
|
events_categories.forEach(async event_category => {
|
||||||
// Retrieve events
|
// Retrieve events
|
||||||
const events = await readdir(`${__dirname}/${event_category}`);
|
const events = await readdir(`./src/events/${event_category}`);
|
||||||
|
|
||||||
// Load them into the client
|
// Load them into the client
|
||||||
Promise.all(
|
Promise.all(
|
||||||
|
@ -16,10 +16,9 @@ export default async (client: Client) => {
|
||||||
`../events/${event_category}/${event_file}`
|
`../events/${event_category}/${event_file}`
|
||||||
);
|
);
|
||||||
|
|
||||||
// Remove extension
|
// Remove .ts
|
||||||
const event_type_ext = event_file.split('.');
|
const event_type_ext = event_file.split('.');
|
||||||
const ext = event_type_ext.pop();
|
if (event_type_ext.pop() !== 'ts') {
|
||||||
if (!(ext === 'js' || ext === 'ts')) {
|
|
||||||
throw `Unknown file in ${event_category}: ${event_file}`;
|
throw `Unknown file in ${event_category}: ${event_file}`;
|
||||||
}
|
}
|
||||||
const event_type = event_type_ext.join('.');
|
const event_type = event_type_ext.join('.');
|
||||||
|
|
Loading…
Reference in a new issue