-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathshard.js
96 lines (90 loc) · 2.41 KB
/
shard.js
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
const path = require("path");
const { EmbedBuilder, WebhookClient, ShardingManager } = require("discord.js");
const config = require("./config");
const Konsol = require("./functions/beautifulConsole");
const konsol = new Konsol();
const webhook = new WebhookClient({
url: config.shardWebhookURL,
});
const manager = new ShardingManager(path.join(__dirname, "index.js"), {
totalShards: "auto",
token: config.token,
});
manager.on("shardCreate", async (shard) => {
shard.on("ready", async () => {
konsol.log(
`${shard.id} numaralı shard başarıyla çalıştırıldı!`,
`SHARD ${shard.id}`,
{
hex: "#32d124",
timeout: 5000,
}
);
webhook.send({
embeds: [
new EmbedBuilder()
.setColor("Green")
.setDescription(
`\`#${shard.id}\` - ID'li shard başarıyla başlatıldı`
),
],
});
});
shard.on("reconnecting", async () => {
konsol.log(
`${shard.id} numaralı shard yeniden başlatıldı!`,
`SHARD ${shard.id}`,
{
hex: "#FFB02F",
timeout: 5000,
}
);
webhook.send({
embeds: [
new EmbedBuilder()
.setColor("Blue")
.setDescription(
`\`#${shard.id}\` - ID'li shard yeniden başlatılıyor`
),
],
});
});
shard.on("death", async () => {
konsol.error(
`${shard.id} numaralı shard çöktü, yeniden başlatılıyor!`,
"ERROR",
{
timeout: 1000,
}
);
const death = new EmbedBuilder()
.setColor("Blue")
.setDescription(
`\`#${shard.id}\` - ID'li shard çöktü, yeniden başlatılıyor`
);
webhook.send({ embeds: [death] });
});
shard.on("disconnect", async () => {
konsol.error(
`${shard.id} numaralı shard çöktü, yeniden başlatılıyor!`,
"ERROR",
{
timeout: 1000,
}
);
const disconnect = new EmbedBuilder()
.setColor("Red")
.setDescription(`\`#${shard.id}\` - ID'li shard yeniden başlatılıyor`);
webhook.send({ embeds: [disconnect] });
});
shard.on("error", async () => {
konsol.error(`${shard.id} numaralı shard hatalı!`, "ERROR", {
timeout: 1000,
});
const error = new EmbedBuilder()
.setColor("DarkAqua")
.setDescription(`\`#${shard.id}\` - ID'li shard hatalı`);
webhook.send({ embeds: [error] });
});
});
manager.spawn();