Skip to content

Commit

Permalink
fix: file import not working on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
dankerow committed May 28, 2024
1 parent 98cdcf8 commit db5dde6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/structures/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import _config from '@/config'
import { loadConfig } from '@/utils/configLoader'
import { readdir } from 'node:fs/promises'
import { join } from 'node:path'
import { pathToFileURL } from 'node:url'
import { Client, GatewayIntentBits, Options, Partials, REST, Routes } from 'discord.js'
import { consola } from 'consola'

Expand Down Expand Up @@ -90,7 +91,7 @@ export class Blop extends Client<true> {
const start = process.hrtime()

try {
const categoryNames = await readdir(join(this.config.dirs.commands))
const categoryNames = await readdir(this.config.dirs.commands)

for (const categoryName of categoryNames) {
const commandFileNames = await readdir(join(this.config.dirs.commands, categoryName))
Expand All @@ -99,7 +100,10 @@ export class Blop extends Client<true> {
try {
totalCommands++

const CommandImport = await import(join(this.config.dirs.commands, categoryName, commandFileName)) as { default: new (...args: any[]) => Command }
const commandPath = join(this.config.dirs.commands, categoryName, commandFileName);
const commandPathUrl = pathToFileURL(commandPath).href

const CommandImport = await import(commandPathUrl) as { default: new (...args: any[]) => Command }
const CommandClass = CommandImport.default
const command: Command = new CommandClass(this)

Expand Down

0 comments on commit db5dde6

Please sign in to comment.