feat: basic sharding support #154
3 changed files with 16 additions and 8 deletions
6
src/bot.ts
Normal file
6
src/bot.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
/** Load the app */
|
||||
const start_app = () => {
|
||||
import("./load").then((l) => l.run().catch((error) => console.error(error)));
|
||||
};
|
||||
|
||||
start_app();
|
17
src/index.ts
17
src/index.ts
|
@ -1,17 +1,20 @@
|
|||
/** Load the app. */
|
||||
const start_app = () => {
|
||||
import("./load").then((l) => l.run().catch((error) => console.error(error)));
|
||||
import { ShardingManager } from "discord.js";
|
||||
|
||||
const start_manager = () => {
|
||||
const manager = new ShardingManager("./dist/bot.js", { token: process.env.TOKEN_DISCORD });
|
||||
|
||||
manager.on("shardCreate", (shard) => console.log(`Launched shard ${shard.id}`));
|
||||
|
||||
manager.spawn();
|
||||
};
|
||||
|
||||
// Load .env if not in prod
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
import("dotenv").then((c) => {
|
||||
c.config({ path: "./config/.env" });
|
||||
|
||||
start_app();
|
||||
start_manager();
|
||||
});
|
||||
} else {
|
||||
start_app();
|
||||
start_manager();
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import { YoutubeiExtractor } from "discord-player-youtubei";
|
|||
/** Creation of the client and definition of its properties */
|
||||
export default async () => {
|
||||
const client: Client = new Client({
|
||||
shards: "auto",
|
||||
intents: [
|
||||
GatewayIntentBits.Guilds,
|
||||
GatewayIntentBits.GuildMessages,
|
||||
|
|
Loading…
Reference in a new issue