fix: Resolve imports for Windows (#9546)

fix: windows why

Co-authored-by: DD <didinele.dev@gmail.com>
Co-authored-by: Almeida <almeidx@pm.me>
This commit is contained in:
Jiralite
2023-05-08 07:59:53 +01:00
committed by GitHub
parent 280ed0ce08
commit b6162bc5b5
2 changed files with 6 additions and 8 deletions

View File

@@ -1,14 +1,13 @@
import { readdir } from 'node:fs/promises';
import { join } from 'node:path';
import { fileURLToPath, URL } from 'node:url';
import { URL } from 'node:url';
import { Client, GatewayIntentBits } from 'discord.js';
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
const eventsPath = fileURLToPath(new URL('events', import.meta.url));
const eventsPath = new URL('events/', import.meta.url);
const eventFiles = await readdir(eventsPath).then((files) => files.filter((file) => file.endsWith('.js')));
for (const file of eventFiles) {
const event = (await import(join(eventsPath, file))).default;
const event = (await import(new URL(file, eventsPath).toString())).default;
client[event.once ? 'once' : 'on'](event.name, async (...args) => event.execute(...args));
}

View File

@@ -1,18 +1,17 @@
import { readdir } from 'node:fs/promises';
import { join } from 'node:path';
import { fileURLToPath, URL } from 'node:url';
import { URL } from 'node:url';
import { Client, GatewayIntentBits } from 'discord.js';
import type { Event } from './events/index.js';
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
const eventsPath = fileURLToPath(new URL('events', import.meta.url));
const eventsPath = new URL('events/', import.meta.url);
const eventFiles = await readdir(eventsPath).then((files) =>
files.filter((file) => file.endsWith('.js') && file !== 'index.js'),
);
for (const file of eventFiles) {
const event: Event = (await import(join(eventsPath, file))).default;
const event: Event = (await import(new URL(file, eventsPath).toString())).default;
client[event.once ? 'once' : 'on'](event.name, async (...args) => event.execute(...args));
}