Optimize database, implement automatic command deployment, and improve project-wide type safety
Some checks failed
Auto Build and Push Docker Image / build (push) Failing after 14s
Some checks failed
Auto Build and Push Docker Image / build (push) Failing after 14s
This commit is contained in:
10
src/index.ts
10
src/index.ts
@@ -7,6 +7,7 @@ import { Command } from './structures/Command.js';
|
||||
import { DB } from './structures/Database.js';
|
||||
import { TwitchManager } from './structures/TwitchManager.js';
|
||||
import { ReminderManager } from './structures/ReminderManager.js';
|
||||
import { Deployer } from './structures/Deployer.js';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
@@ -15,12 +16,11 @@ const __dirname = dirname(__filename);
|
||||
DB.init();
|
||||
|
||||
const client = new ExtendedClient();
|
||||
// Make DB available on client
|
||||
(client as any).DB = DB;
|
||||
|
||||
// Load Commands
|
||||
const commandsPath = join(__dirname, 'commands');
|
||||
const commandFolders = readdirSync(commandsPath);
|
||||
const commandData: any[] = [];
|
||||
|
||||
for (const folder of commandFolders) {
|
||||
const folderPath = join(commandsPath, folder);
|
||||
@@ -33,6 +33,7 @@ for (const folder of commandFolders) {
|
||||
|
||||
if (command && 'data' in command && 'execute' in command) {
|
||||
client.commands.set(command.data.name, command);
|
||||
commandData.push(command.data.toJSON());
|
||||
console.log(`[COMMAND] Loaded: ${command.data.name}`);
|
||||
} else {
|
||||
console.warn(`[COMMAND] The command at ${filePath} is missing a required "data" or "execute" property.`);
|
||||
@@ -40,6 +41,11 @@ for (const folder of commandFolders) {
|
||||
}
|
||||
}
|
||||
|
||||
// Auto-deploy commands if configured (default: true)
|
||||
if (process.env.AUTO_DEPLOY !== 'false' && process.env.CLIENT_ID && process.env.DISCORD_TOKEN) {
|
||||
await Deployer.deployCommands(process.env.CLIENT_ID, process.env.DISCORD_TOKEN, commandData);
|
||||
}
|
||||
|
||||
// Load Events
|
||||
const eventsPath = join(__dirname, 'events');
|
||||
const eventFiles = readdirSync(eventsPath).filter(file => file.endsWith('.ts') || file.endsWith('.js'));
|
||||
|
||||
Reference in New Issue
Block a user