Compare commits

...

2 commits

Author SHA1 Message Date
5fa03d8097
works with dev and prod 2022-07-20 13:55:08 +02:00
d46a48380c
add npx 2022-07-20 12:53:01 +02:00
3 changed files with 11 additions and 10 deletions

View file

@ -4,8 +4,8 @@
"description": "Bot discord",
"main": "src/index.js",
"scripts": {
"main": "tsc && node ./dist/index.js",
"debug": "tsnd --respawn ./src/index.ts",
"main": "npx tsc && node ./dist/index.js",
"debug": "npx tsnd --respawn ./src/index.ts",
"lint": "npx eslint src"
},
"repository": {

View file

@ -6,15 +6,15 @@ import { readdir } from 'fs/promises';
export default async (client: Client) => {
const rest = new REST({ version: '9' }).setToken(client.token ?? '');
const command_categories = (await readdir('./src/commands'))
.filter(element => !element.endsWith('.ts'));
const command_categories = (await readdir(__dirname))
.filter(element => !element.endsWith('.js') && !element.endsWith('.ts'));
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}`);
const command_files = await readdir(`${__dirname}/${command_category}`);
// Add the command
return Promise.all(

View file

@ -2,12 +2,12 @@ import { Client } from 'discord.js';
import { readdir } from 'fs/promises';
export default async (client: Client) => {
const events_categories = (await readdir('./src/events'))
.filter(element => !element.endsWith('.ts'));
const events_categories = (await readdir(__dirname))
.filter(element => !element.endsWith('.js') && !element.endsWith('.ts'));
events_categories.forEach(async event_category => {
// Retrieve events
const events = await readdir(`./src/events/${event_category}`);
const events = await readdir(`${__dirname}/${event_category}`);
// Load them into the client
Promise.all(
@ -16,9 +16,10 @@ export default async (client: Client) => {
`../events/${event_category}/${event_file}`
);
// Remove .ts
// Remove extension
const event_type_ext = event_file.split('.');
if (event_type_ext.pop() !== 'ts') {
const ext = event_type_ext.pop();
if (!(ext === 'js' || ext === 'ts')) {
throw `Unknown file in ${event_category}: ${event_file}`;
}
const event_type = event_type_ext.join('.');