refactor(index): using the new system log
This commit is contained in:
parent
a9ac3eeec8
commit
b41ccc2468
1 changed files with 14 additions and 10 deletions
24
src/index.ts
24
src/index.ts
|
|
@ -1,10 +1,14 @@
|
||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import 'dotenv/config';
|
import 'dotenv/config';
|
||||||
import { Client, Collection, GatewayIntentBits, REST, Routes } from 'discord.js';
|
import {
|
||||||
import { PrismaClient } from '@prisma/client';
|
Client,
|
||||||
|
Collection,
|
||||||
const prisma = new PrismaClient();
|
GatewayIntentBits,
|
||||||
|
REST,
|
||||||
|
Routes,
|
||||||
|
} from 'discord.js';
|
||||||
|
import { log } from '@lib/log';
|
||||||
|
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
intents: [
|
intents: [
|
||||||
|
|
@ -22,7 +26,7 @@ const commandFolders = fs.readdirSync(commandFolderPath);
|
||||||
|
|
||||||
const commands = [];
|
const commands = [];
|
||||||
|
|
||||||
console.log('\n🔍 | Commands search:');
|
log.search('Commands');
|
||||||
for (const folder of commandFolders) {
|
for (const folder of commandFolders) {
|
||||||
const commandsPath = path.join(commandFolderPath, folder);
|
const commandsPath = path.join(commandFolderPath, folder);
|
||||||
const commandFiles = fs
|
const commandFiles = fs
|
||||||
|
|
@ -36,11 +40,11 @@ for (const folder of commandFolders) {
|
||||||
if ('data' in command && 'execute' in command) {
|
if ('data' in command && 'execute' in command) {
|
||||||
client.commands.set(command.data.name, command);
|
client.commands.set(command.data.name, command);
|
||||||
commands.push(command.data.toJSON());
|
commands.push(command.data.toJSON());
|
||||||
console.log(`\t✅ | ${command.data.name}`);
|
log.list(command.data.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(`\t⚠️ | Command at ${file}\n\t\t(${err as Error}).`);
|
log.error(err, `Command at ${file}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -49,7 +53,7 @@ console.log('\n\n');
|
||||||
const eventFolderPath = path.join(__dirname, 'events');
|
const eventFolderPath = path.join(__dirname, 'events');
|
||||||
const eventFolders = fs.readdirSync(eventFolderPath);
|
const eventFolders = fs.readdirSync(eventFolderPath);
|
||||||
|
|
||||||
console.log('\n🔍 | Events search:');
|
log.search('Events');
|
||||||
for (const folder of eventFolders) {
|
for (const folder of eventFolders) {
|
||||||
const eventsPath = path.join(eventFolderPath, folder);
|
const eventsPath = path.join(eventFolderPath, folder);
|
||||||
const eventFiles = fs
|
const eventFiles = fs
|
||||||
|
|
@ -67,11 +71,11 @@ for (const folder of eventFolders) {
|
||||||
else {
|
else {
|
||||||
client.on(event.name, (...args) => event.execute(...args));
|
client.on(event.name, (...args) => event.execute(...args));
|
||||||
}
|
}
|
||||||
console.log(`\t✅ | ${event.name}`);
|
log.list(event.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(`\t⚠️ | Event at ${file}\n\t\t(${err as Error}).`);
|
log.error(err, `Event at ${file}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue