ElektraZale
ElektraZale3mo ago

dynamic import fail

alright, so i had another issue aside from this but I figured it out, though its a very clearly ugly fix... just ignore that.. Anyways, this hangs on the import statement...
for (const folder of commandFolders) {
//
const commandsPath = path.join(foldersPath, folder);
const commandFiles = fs.readdirSync(commandsPath).filter((file) =>
//Filter any and all files
// that end with ts
file.endsWith(".ts")
);
for (const file of commandFiles) {
//Join Commands/x with /file.tx
const filePath = path.join(commandsPath, file);

//import the command from file
// deno-lint-ignore prefer-const
let command = await import("file://" + filePath) as BotCommand;

//Add command to the list
commands.push(command.data.toJSON());
}
}
for (const folder of commandFolders) {
//
const commandsPath = path.join(foldersPath, folder);
const commandFiles = fs.readdirSync(commandsPath).filter((file) =>
//Filter any and all files
// that end with ts
file.endsWith(".ts")
);
for (const file of commandFiles) {
//Join Commands/x with /file.tx
const filePath = path.join(commandsPath, file);

//import the command from file
// deno-lint-ignore prefer-const
let command = await import("file://" + filePath) as BotCommand;

//Add command to the list
commands.push(command.data.toJSON());
}
}
No description
2 Replies
ElektraZale
ElektraZaleOP3mo ago
No description
ElektraZale
ElektraZaleOP3mo ago
code has since now changed, it's still hanging thoo
for await (const folder of Deno.readDir(foldersPath)) {
if (folder.isDirectory) {
const commandsPath = path.join("./Commands", folder.name);
const commandFiles = fs.readdirSync(commandsPath).filter((file) =>
//Filter any and all files
// that end with ts
file.endsWith(".ts")
);
for (const file of commandFiles) {
//Join Commands/x with /file.tx
const filePath = path.join(commandsPath, file);

//import the command from file
// deno-lint-ignore prefer-const
let command = await import(`./${filePath}`) as BotCommand;

//Add command to the list
commands.push(command.data.toJSON());
}
}
}
for await (const folder of Deno.readDir(foldersPath)) {
if (folder.isDirectory) {
const commandsPath = path.join("./Commands", folder.name);
const commandFiles = fs.readdirSync(commandsPath).filter((file) =>
//Filter any and all files
// that end with ts
file.endsWith(".ts")
);
for (const file of commandFiles) {
//Join Commands/x with /file.tx
const filePath = path.join(commandsPath, file);

//import the command from file
// deno-lint-ignore prefer-const
let command = await import(`./${filePath}`) as BotCommand;

//Add command to the list
commands.push(command.data.toJSON());
}
}
}
nvm TS community helped me fix

Did you find this page helpful?