mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
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:
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user