mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 01:23:31 +01:00
fix(scripts): read directory and rerun (#8065)
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
import { readdir, writeFile } from 'node:fs/promises';
|
||||
import { GatewayDispatchEvents } from '../src/index.js';
|
||||
|
||||
async function writeWebsocketHandlerImports() {
|
||||
const lines = ["'use strict';\n", 'const handlers = Object.fromEntries(['];
|
||||
|
||||
for (const name of Object.values(GatewayDispatchEvents)) {
|
||||
lines.push(` ['${name}', require('./${name}')],`);
|
||||
const handlersDirectory = new URL('../src/client/websocket/handlers', import.meta.url);
|
||||
|
||||
for (const file of await (await readdir(handlersDirectory)).sort()) {
|
||||
if (file === 'index.js') continue;
|
||||
|
||||
lines.push(` ['${file.slice(0, -3)}', require('./${file.slice(0, -3)}')],`);
|
||||
}
|
||||
|
||||
lines.push(']);\n\nmodule.exports = handlers;\n');
|
||||
|
||||
Reference in New Issue
Block a user