Remove old imports
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
import { Client } from 'discord.js';
|
import { Client } from 'discord.js';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { pathToFileURL } from 'url';
|
|
||||||
import { Handler } from '../types';
|
import { Handler } from '../types';
|
||||||
|
|
||||||
const ROOT_DIR = path.resolve(__dirname, '..');
|
const ROOT_DIR = path.resolve(__dirname, '..');
|
||||||
@@ -11,7 +10,8 @@ export async function loadHandlersFrom(dir: string, handlerArray: Handler[]): Pr
|
|||||||
|
|
||||||
const files = fs.readdirSync(`${ROOT_DIR}/${dir}`).filter(file => file.endsWith('.js') || file.endsWith('.ts'));
|
const files = fs.readdirSync(`${ROOT_DIR}/${dir}`).filter(file => file.endsWith('.js') || file.endsWith('.ts'));
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
handlerArray.push((await import(pathToFileURL(`${ROOT_DIR}/${dir}/${file}`).href)).default);
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||||
|
handlerArray.push(require(`${ROOT_DIR}/${dir}/${file}`).default);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { Client, REST, RESTPostAPIApplicationCommandsJSONBody, Routes } from 'discord.js';
|
import { Client, REST, RESTPostAPIApplicationCommandsJSONBody, Routes } from 'discord.js';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { pathToFileURL } from 'url';
|
|
||||||
import { config } from '../config';
|
import { config } from '../config';
|
||||||
import { Command } from '../types';
|
import { Command } from '../types';
|
||||||
|
|
||||||
@@ -21,7 +20,8 @@ export async function refreshCommands(client: Client) {
|
|||||||
for (const [folderName, files] of Object.entries(commandFiles)) {
|
for (const [folderName, files] of Object.entries(commandFiles)) {
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
const p = `${ROOT_DIR}/${folderName}/${file}`;
|
const p = `${ROOT_DIR}/${folderName}/${file}`;
|
||||||
const command: Command = (await import(pathToFileURL(p).href)).default;
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||||
|
const command: Command = require(p).default;
|
||||||
|
|
||||||
if (!command) {
|
if (!command) {
|
||||||
console.warn(`File at ${p} has no export. Skipping registering.`);
|
console.warn(`File at ${p} has no export. Skipping registering.`);
|
||||||
|
|||||||
+1
-3
@@ -3,13 +3,11 @@
|
|||||||
"strict": true,
|
"strict": true,
|
||||||
"noUnusedLocals": true,
|
"noUnusedLocals": true,
|
||||||
"noImplicitAny": false,
|
"noImplicitAny": false,
|
||||||
|
|
||||||
"moduleResolution": "bundler",
|
"moduleResolution": "bundler",
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
|
|
||||||
"lib": ["ES2021.String"],
|
"lib": ["ES2021.String"],
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"inlineSourceMap": true,
|
"inlineSourceMap": true,
|
||||||
"forceConsistentCasingInFileNames": false
|
"forceConsistentCasingInFileNames": false
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user