refactor: Update import statements and configurations for ES module compatibility

This commit is contained in:
2025-04-25 00:41:40 +08:00
parent c613ef3f35
commit 1aa97a8a7a
14 changed files with 237 additions and 115 deletions

View File

@@ -1,7 +1,7 @@
import { REST, Routes, APIApplicationCommand } from "discord.js";
import fs from "node:fs";
import path from "node:path";
import logger from "./src/utils/logger"; // Use default import now
import logger from "./src/utils/logger.js"; // Added .js extension for ES modules
import dotenv from "dotenv";
// --- Setup ---
@@ -33,8 +33,9 @@ const loadCommandsForDeployment = async () => {
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
try {
// Use dynamic import
const commandModule = await import(filePath);
// Use dynamic import with file:// protocol for ES modules
const fileUrl = new URL(`file://${filePath}`);
const commandModule = await import(fileUrl.href);
// Assuming commands export default or have a 'default' property
const command = commandModule.default || commandModule;