refactor: Update import statements and configurations for ES module compatibility
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user