I'm trying to configure the shard system in my bot, developed in TypeScript, however, when I configure the main file, discord.js itself does not recognize the file written in ts.
Here's the error:
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for C:\Users\.\Documents\Programação\Discord\Pessoal\Tom5\Tom5#v6\src\bot.ts
The launcher.ts file (responsible for creating the shards):
import chalk from "chalk";
import { ShardingManager } from "discord.js";
export class ShardsManager extends ShardingManager {
constructor() {
super(
"src/bot.ts",
{
token: "", //I've been putting the bot's token here
respawn: true,
totalShards: "auto",
}
)
this.on("shardCreate", (shard) => {
console.log(
chalk.bold.green(
`[SHARD - ${shard.id + 1}]`
),
"Criada"
)
})
this.spawn()
}
}
new ShardsManager()
The main file (bot.ts):
import chalk from "chalk";
import Tom5 from "./classes/Tom5";
import * as dotenv from "dotenv"
dotenv.config()
process.on('unhandledRejection', (reason, p) => {
console.log(
chalk.bold.red(
"[SCRIPT REJEITADO]\n"
),
reason
)
});
process.on("uncaughtException", (err, origin) => {
console.log(
chalk.bold.red(
"[ERRO CAPTURADO]\n"
),
err
)
})
process.on('uncaughtExceptionMonitor', (err, origin) => {
console.log(
chalk.bold.red(
"[SCRIPT BLOQUEADO]\n"
),
err
)
});
await new Tom5().init()
Best regards, TomG
I tried to rename the file to bot.js
, however, it caused multiples unnecessary errors, especially importing typescript files