-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
128 lines (116 loc) · 2.83 KB
/
index.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
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
// Imports the client library
const { Routes } = require("discord-api-types/v10");
const fs = require("fs");
const keep_alive = require("./keep_alive.js");
const secret = require("./config.json");
// Creates clients
const {
Client,
ComponentType,
REST,
Intents,
Embed,
Embedbuilder,
EnumResolvers,
GatewayIntendBits,
Partials,
ApplicationCommandType,
ApplicationCommandOptionType,
ButtonStyle,
Colors,
Collection,
MessageEmbed,
MessageAttachment,
ButtonBuilder,
WebhookClient,
} = require("discord.js");
const client = new Client({
messageCacheLifetime: 60,
fetchAllMembers: false,
messageCacheMaxSize: 10,
restTimeOffset: 0,
restWsBridgetimeout: 100,
shards: "auto",
allowedMentions: {
parse: ["roles", "users", "everyone"],
repliedUser: true,
},
partials: [
Partials.Message,
Partials.Channel,
Partials.GuildMember,
Partials.Reaction,
Partials.GuildScheduledEvent,
Partials.User,
Partials.ThreadMember,
Partials.enum,
],
intents: [
"Guilds",
"GuildMembers",
"GuildBans",
"GuildEmojisAndStickers",
"GuildIntegrations",
"GuildWebhooks",
"GuildInvites",
"GuildVoiceStates",
"GuildPresences",
"GuildMessages",
"GuildMessageReactions",
"GuildMessageTyping",
"DirectMessages",
"DirectMessageReactions",
"DirectMessageTyping",
"MessageContent",
],
});
client.setMaxListeners(50);
process.setMaxListeners(50);
for (const collection of [
"info",
"cmd",
"music",
"aliases",
"categories",
"events",
"slashCommands",
]) {
client[collection] = new Collection();
}
client.categories = fs.readdirSync("./Commands");
// Export
module.exports = client;
["command", "mjs", "event", "slash"].forEach((handler) => {
require(`./structures/${handler}`)(client);
});
// Emoji
client.emotes = {
play: "▶️",
stop: "⏹️",
queue: "📄",
success: "☑️",
repeat: "🔁",
error: "❌",
};
// Show time
let date_ob = new Date();
let full_date = date_ob.toISOString().split("T")[0];
let date_time = date_ob.toISOString().replace("T", " ").split(".")[0];
let time = date_ob.toTimeString().split(" ")[0];
console.log(`${full_date}\n${date_time}\n${time}`);
// if there are errors, log them
client
.on("disconnect", () => console.log("Bot is disconnecting...", "warn"))
.on("reconnecting", () => console.log("Bot reconnecting...", "log"))
.on("error", (e) => console.log(date_time, e, "error"))
.on("warn", (info) => console.log(date_time, info, "warn"));
// if there is an unhandledRejection, log them
process.on("unhandledRejection", (err) => {
console.log(`[ERROR] Unhandled promise rejection: ${err.message}.`);
console.log(err);
client.channels.fetch("994459707580358656").then((channel) => {
channel.send(`Unhandled Promise Rejection: ${err}`);
});
});
// Login
client.login(secret.token);