Repository navigation
Expand file tree
/
Copy pathengine.js
More file actions
168 lines (151 loc) · 5.24 KB
/
Copy pathengine.js
File metadata and controls
168 lines (151 loc) · 5.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
const {
Partials,
GatewayIntentBits,
ActivityType,
PresenceUpdateStatus,
Collection,
Options,
LimitedCollection,
} = require("discord.js");
const { Indomitable } = require("indomitable");
require("dotenv").config();
require("module-alias/register");
require("./src/index");
const TealClient = require("./src/structure/client");
const customClientOptions = {
partials: [Partials.User, Partials.Message, Partials.Reaction],
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.MessageContent],
presence: {
activities: [{ name: `Booting up`, type: ActivityType.Playing }],
status: PresenceUpdateStatus.DoNotDisturb,
},
failIfNotExists: false,
allowedMentions: { repliedUser: false },
sweepers: {
...Options.DefaultSweeperSettings,
guildMembers: {
interval: 1800,
filter: () => (member) => !(member.id === member.client.user?.id),
},
},
makeCache: (manager) => {
switch (manager.name) {
case "GuildTextThreadManager":
case "GuildMessageManager":
case "GuildForumThreadManager":
case "ReactionManager":
case "DMMessageManager":
case "GuildScheduledEventManager":
case "ApplicationCommandManager":
case "AutoModerationRuleManager":
case "GuildApplicationCommandManager":
case "ApplicationCommandPermissionsManager":
case "ThreadMemberManager":
case "BaseGuildEmojiManager":
case "GuildEmojiManager":
case "GuildEmojiRoleManager":
case "GuildInviteManager":
case "GuildStickerManager":
case "StageInstanceManager":
case "PresenceManager":
case "MessageManager":
case "GuildBanManager":
case "ThreadManager":
case "ReactionUserManager":
return new LimitedCollection({ maxSize: 0 });
case "GuildMemberManager":
return new LimitedCollection({
maxSize: 20000,
keepOverLimit: (member) => member.id === member.client.user.id,
});
case "UserManager":
return new LimitedCollection({
maxSize: 0,
keepOverLimit: (user) => user.id === user.client.user.id,
});
default:
return new Collection();
}
},
};
const sharderOptions = {
clientOptions: { ...customClientOptions },
client: TealClient,
autoRestart: true,
token: process.env.BOT_TOKEN,
clusterCount: 1,
shardCount: 1,
clusterSettings: { execArgv: ["--enable-source-maps"] },
autoRestart: true,
handleConcurrency: true,
spawnTimeout: 60000,
waitForReady: true,
};
const manager = new Indomitable({ ...sharderOptions }).on("error", console.error);
manager
.on("debug", (d) => {
if (d.includes("eval")) return;
console.log(`[ClusterHandler] :`.blue.dim + d.blue);
})
.on("error", (err) => {
console.log(`[ClusterHandler] :`.blue.dim + { err }, "Couldn't start shards");
})
.on("workerReady", (cluster) => {
console.log({ worker_id: cluster.id }, "Worker ready");
})
.on("workerExit", (code, signal, cluster) => {
console.log({ worker_id: cluster.id, code, signal }, "Worker exit");
})
.on("shardReady", (event) => {
console.log({ worker_id: event.clusterId, shard_id: event.shardId }, "Shard ready");
})
.on("shardDisconnect", (event) => {
console.log({ worker_id: event.clusterId, shard_id: event.shardId }, "Shard disconnect");
})
.on("shardReconnect", (event) => {
console.log({ worker_id: event.clusterId, shard_id: event.shardId }, "Shard reconnect");
});
manager.spawn();
/*
manager.on("workerReady", (cluster) => {
console.log(
`[SHARDING-MANAGER] `.america +
`[Teal Music]: `.blue +
`Launched Cluster #${cluster.id} | ${cluster.id + 1}/${cluster.manager.totalClusters} [${
cluster.manager.shardsPerClusters
}/${cluster.manager.totalShards} Shards]`.yellow
);
cluster.on("death", function () {
console.log(`[Teal Music]: `.blue + `${colors.red.bold(`Cluster ${cluster.id} died..`)}`);
});
cluster.on("error", (e) => {
console.log(`[Teal Music]: `.blue + `${colors.red.bold(`Cluster ${cluster.id} errored ..`)}`);
console.error(e);
});
cluster.on("disconnect", function () {
console.log(`[Teal Music]: `.blue + `${colors.red.bold(`Cluster ${cluster.id} disconnected..`)}`);
});
cluster.on("reconnecting", function () {
console.log(`[Teal Music]: `.blue + `${colors.yellow.bold(`Cluster ${cluster.id} reconnecting..`)}`);
});
cluster.on("close", function (code) {
console.log(`[Teal Music]: `.blue + `${colors.red.bold(`Cluster ${cluster.id} close with code ${code}`)}`);
});
cluster.on("exit", function (code) {
console.log(`[Teal Music]: `.blue + `${colors.red.bold(`Cluster ${cluster.id} exited with code ${code}`)}`);
});
cluster.on("message", async (msg) => {
if (msg.log) {
console.log(`[Teal Music]: `.blue + msg.log);
}
});
});
manager.once("debug", (d) =>
d.includes("[CM => Manager] [Spawning Clusters]") ? console.log(`Teal Music: `.yellow + d) : ""
);
manager.spawn({ timeout: -1, delay: 7000 }).then(() => {
setInterval(async () => {
await manager.broadcastEval(`this.ws.status && this.isReady() ? this.ws.reconnect() : 0`);
}, 360000);
}).catch((reason) => console.error("Shard spawn has occured a error", reason));
*/