apexify.js 2.4.1 → 2.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -55,7 +55,7 @@ exports.LevelingSystem = void 0;
|
|
|
55
55
|
var events_1 = require("events");
|
|
56
56
|
var utils_1 = require("../../../database/utils");
|
|
57
57
|
var levels_card_1 = require("../../../canvas/themes/levels-card");
|
|
58
|
-
var
|
|
58
|
+
var cLevelsArray_json_1 = require("./cLevelsArray.json");
|
|
59
59
|
var LevelingSystem = /** @class */ (function (_super) {
|
|
60
60
|
__extends(LevelingSystem, _super);
|
|
61
61
|
function LevelingSystem(config) {
|
|
@@ -66,7 +66,7 @@ var LevelingSystem = /** @class */ (function (_super) {
|
|
|
66
66
|
_this.rate = (config === null || config === void 0 ? void 0 : config.rate) || 2;
|
|
67
67
|
_this.channelId = (config === null || config === void 0 ? void 0 : config.channelId) || null;
|
|
68
68
|
_this.guildId = (config === null || config === void 0 ? void 0 : config.guildId) || null;
|
|
69
|
-
_this.levelsArray = (config === null || config === void 0 ? void 0 : config.levelsArray) ||
|
|
69
|
+
_this.levelsArray = (config === null || config === void 0 ? void 0 : config.levelsArray) || cLevelsArray_json_1.default;
|
|
70
70
|
_this.levelingMessage = (config === null || config === void 0 ? void 0 : config.levelUpMessage) || 'Congrates {user} you level up to level {level}.';
|
|
71
71
|
return _this;
|
|
72
72
|
}
|
|
@@ -133,11 +133,11 @@ var LevelingSystem = /** @class */ (function (_super) {
|
|
|
133
133
|
LevelingSystem.prototype.xpCard = function (context, guildId, userId, version) {
|
|
134
134
|
if (version === void 0) { version = 1; }
|
|
135
135
|
return __awaiter(this, void 0, void 0, function () {
|
|
136
|
-
var search, rank, sortedLevels, userRank, userIndex, nextLevelIndex, nextLevelData, card, error_2;
|
|
136
|
+
var search, fetchServer, rank, sortedLevels, userRank, userIndex, nextLevelIndex, nextLevelData, card, error_2;
|
|
137
137
|
return __generator(this, function (_a) {
|
|
138
138
|
switch (_a.label) {
|
|
139
139
|
case 0:
|
|
140
|
-
_a.trys.push([0,
|
|
140
|
+
_a.trys.push([0, 5, , 6]);
|
|
141
141
|
if (!context) {
|
|
142
142
|
throw new Error('Error: Interaction/Message parameter is required. Usage: xpCard(interaction, guildId, userId). You can replace interaction with message if prefix.');
|
|
143
143
|
}
|
|
@@ -150,13 +150,16 @@ var LevelingSystem = /** @class */ (function (_super) {
|
|
|
150
150
|
return [4 /*yield*/, (0, utils_1.find)(this.levelsCollection, { userId: userId, guildId: guildId })];
|
|
151
151
|
case 1:
|
|
152
152
|
search = _a.sent();
|
|
153
|
+
return [4 /*yield*/, (0, utils_1.find)(this.configCollection, { guildId: guildId })];
|
|
154
|
+
case 2:
|
|
155
|
+
fetchServer = _a.sent();
|
|
153
156
|
if (!search) {
|
|
154
157
|
return [2 /*return*/, 'No data found for this user'];
|
|
155
158
|
}
|
|
156
159
|
return [4 /*yield*/, (0, utils_1.searchMany)([
|
|
157
160
|
{ collectionName: this.levelsCollection, displayment: null, filter: { guildId: guildId } },
|
|
158
161
|
])];
|
|
159
|
-
case
|
|
162
|
+
case 3:
|
|
160
163
|
rank = _a.sent();
|
|
161
164
|
sortedLevels = rank.levelsCollection.sort(function (a, b) {
|
|
162
165
|
return b.xpCount - a.xpCount;
|
|
@@ -171,23 +174,23 @@ var LevelingSystem = /** @class */ (function (_super) {
|
|
|
171
174
|
}
|
|
172
175
|
nextLevelIndex = search.level + 1;
|
|
173
176
|
nextLevelData = void 0;
|
|
174
|
-
if (nextLevelIndex <
|
|
175
|
-
nextLevelData =
|
|
177
|
+
if (nextLevelIndex < fetchServer.levelsArray.length) {
|
|
178
|
+
nextLevelData = fetchServer.levelsArray[nextLevelIndex];
|
|
176
179
|
}
|
|
177
180
|
else {
|
|
178
181
|
nextLevelData = { level: 'max', xpCount: 'max' };
|
|
179
182
|
}
|
|
180
|
-
return [4 /*yield*/, (0, levels_card_1.xpRank)(context, guildId, userId, search.level, userRank, search.xpCount, nextLevelData.xpCount,
|
|
181
|
-
case
|
|
183
|
+
return [4 /*yield*/, (0, levels_card_1.xpRank)(context, guildId, userId, search.level, userRank, search.xpCount, nextLevelData.xpCount, fetchServer.levelsArray, version, search.bannerURL)];
|
|
184
|
+
case 4:
|
|
182
185
|
card = _a.sent();
|
|
183
186
|
if (!card)
|
|
184
187
|
return [2 /*return*/, 'An Error occurred while drawing users xpCard.'];
|
|
185
188
|
return [2 /*return*/, card];
|
|
186
|
-
case
|
|
189
|
+
case 5:
|
|
187
190
|
error_2 = _a.sent();
|
|
188
191
|
console.log(error_2.message);
|
|
189
192
|
throw new Error("An error occurred while sending xpCard.");
|
|
190
|
-
case
|
|
193
|
+
case 6: return [2 /*return*/];
|
|
191
194
|
}
|
|
192
195
|
});
|
|
193
196
|
});
|
|
@@ -253,7 +256,7 @@ var LevelingSystem = /** @class */ (function (_super) {
|
|
|
253
256
|
$set: {
|
|
254
257
|
userId: userId,
|
|
255
258
|
guildId: guildId,
|
|
256
|
-
xpCount:
|
|
259
|
+
xpCount: fetchServer.XpCount * fetchServer.rate,
|
|
257
260
|
level: 0,
|
|
258
261
|
},
|
|
259
262
|
})];
|
|
@@ -261,22 +264,22 @@ var LevelingSystem = /** @class */ (function (_super) {
|
|
|
261
264
|
updatedUserRecord = _a.sent();
|
|
262
265
|
return [3 /*break*/, 9];
|
|
263
266
|
case 4: return [4 /*yield*/, (0, utils_1.updateData)(this.levelsCollection, { userId: userId, guildId: guildId }, {
|
|
264
|
-
$inc: { xpCount:
|
|
267
|
+
$inc: { xpCount: fetchServer.XpCount * fetchServer.rate },
|
|
265
268
|
})];
|
|
266
269
|
case 5:
|
|
267
270
|
updatedUserRecord = _a.sent();
|
|
268
|
-
if (!(updatedUserRecord.data.xpCount >=
|
|
271
|
+
if (!(updatedUserRecord.data.xpCount >= fetchServer.levelsArray[fetchServer.levelsArray.length - 1].xpCount)) return [3 /*break*/, 7];
|
|
269
272
|
return [4 /*yield*/, (0, utils_1.updateData)(this.levelsCollection, { userId: userId, guildId: guildId }, {
|
|
270
273
|
$set: {
|
|
271
|
-
xpCount:
|
|
272
|
-
level:
|
|
274
|
+
xpCount: fetchServer.levelsArray[fetchServer.levelsArray.length - 1].xpCount,
|
|
275
|
+
level: fetchServer.levelsArray[fetchServer.levelsArray.length - 1].level,
|
|
273
276
|
},
|
|
274
277
|
})];
|
|
275
278
|
case 6:
|
|
276
279
|
_a.sent();
|
|
277
280
|
return [2 /*return*/, "".concat(userId, " reached maximum level")];
|
|
278
281
|
case 7:
|
|
279
|
-
levelUp = this.checkLevelUp(updatedUserRecord.data);
|
|
282
|
+
levelUp = this.checkLevelUp(updatedUserRecord.data, fetchServer);
|
|
280
283
|
channelData = fetchServer.channelId;
|
|
281
284
|
if (!levelUp) return [3 /*break*/, 9];
|
|
282
285
|
return [4 /*yield*/, (0, utils_1.updateData)(this.levelsCollection, { userId: userId, guildId: guildId }, {
|
|
@@ -340,7 +343,7 @@ var LevelingSystem = /** @class */ (function (_super) {
|
|
|
340
343
|
});
|
|
341
344
|
});
|
|
342
345
|
};
|
|
343
|
-
LevelingSystem.prototype.updateUserLevel = function (userId, guildId) {
|
|
346
|
+
LevelingSystem.prototype.updateUserLevel = function (userId, guildId, fetchServer) {
|
|
344
347
|
return __awaiter(this, void 0, void 0, function () {
|
|
345
348
|
var userRecord, userXp, updatedLevel, _i, _a, levelInfo, error_6;
|
|
346
349
|
return __generator(this, function (_b) {
|
|
@@ -356,7 +359,7 @@ var LevelingSystem = /** @class */ (function (_super) {
|
|
|
356
359
|
}
|
|
357
360
|
userXp = userRecord.xpCount;
|
|
358
361
|
updatedLevel = 0;
|
|
359
|
-
for (_i = 0, _a =
|
|
362
|
+
for (_i = 0, _a = fetchServer.levelsArray; _i < _a.length; _i++) {
|
|
360
363
|
levelInfo = _a[_i];
|
|
361
364
|
if (userXp >= levelInfo.xpCount) {
|
|
362
365
|
updatedLevel = levelInfo.level;
|
|
@@ -380,9 +383,9 @@ var LevelingSystem = /** @class */ (function (_super) {
|
|
|
380
383
|
});
|
|
381
384
|
});
|
|
382
385
|
};
|
|
383
|
-
LevelingSystem.prototype.checkLevelUp = function (userRecord) {
|
|
384
|
-
var level =
|
|
385
|
-
while (level >= 0 && userRecord.xpCount <=
|
|
386
|
+
LevelingSystem.prototype.checkLevelUp = function (userRecord, fetchServer) {
|
|
387
|
+
var level = fetchServer.levelsArray.length - 1;
|
|
388
|
+
while (level >= 0 && userRecord.xpCount <= fetchServer.levelsArray[level].xpCount) {
|
|
386
389
|
level--;
|
|
387
390
|
}
|
|
388
391
|
if (level < 0) {
|
|
@@ -390,7 +393,7 @@ var LevelingSystem = /** @class */ (function (_super) {
|
|
|
390
393
|
this.emit('error', "Invalid level data for user with xpCount: ".concat(userRecord.xpCount));
|
|
391
394
|
return false;
|
|
392
395
|
}
|
|
393
|
-
var nextLevelData =
|
|
396
|
+
var nextLevelData = fetchServer.levelsArray[level];
|
|
394
397
|
if (userRecord.level < nextLevelData.level) {
|
|
395
398
|
userRecord.level = nextLevelData.level;
|
|
396
399
|
return true;
|
|
@@ -663,7 +666,7 @@ var LevelingSystem = /** @class */ (function (_super) {
|
|
|
663
666
|
return [4 /*yield*/, (0, utils_1.updateData)(this.levelsCollection, { guildId: guildId, userId: userId }, { $inc: { xpCount: xpAmount } })];
|
|
664
667
|
case 3:
|
|
665
668
|
update = _a.sent();
|
|
666
|
-
return [4 /*yield*/, this.updateUserLevel(userId, guildId)];
|
|
669
|
+
return [4 /*yield*/, this.updateUserLevel(userId, guildId, searchServer)];
|
|
667
670
|
case 4:
|
|
668
671
|
levelUp = _a.sent();
|
|
669
672
|
if (!(levelUp > prevLevel)) return [3 /*break*/, 7];
|
|
@@ -813,4 +816,4 @@ var LevelingSystem = /** @class */ (function (_super) {
|
|
|
813
816
|
};
|
|
814
817
|
return LevelingSystem;
|
|
815
818
|
}(events_1.EventEmitter));
|
|
816
|
-
exports.LevelingSystem = LevelingSystem;
|
|
819
|
+
exports.LevelingSystem = LevelingSystem;
|
|
@@ -44,38 +44,53 @@ var prefixRegister_1 = require("./prefixRegister");
|
|
|
44
44
|
var slashResponder_1 = require("./slashResponder");
|
|
45
45
|
var prefixResponder_1 = require("./prefixResponder");
|
|
46
46
|
var riffy_1 = require("riffy");
|
|
47
|
-
var
|
|
47
|
+
var utils_1 = require("../../database/utils");
|
|
48
48
|
var start_1 = require("../discord-build/commands-(prefix)/music/functions/start");
|
|
49
49
|
var end_1 = require("../discord-build/commands-(prefix)/music/functions/end");
|
|
50
50
|
var buttons_1 = require("../discord-build/commands-(prefix)/music/functions/buttons");
|
|
51
|
-
var
|
|
51
|
+
var axios_1 = require("axios");
|
|
52
52
|
var fs_1 = require("fs");
|
|
53
|
-
var
|
|
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
|
-
|
|
53
|
+
var express_1 = require("express");
|
|
54
|
+
var colors = {
|
|
55
|
+
reset: "\x1b[0m",
|
|
56
|
+
bright: "\x1b[1m",
|
|
57
|
+
dim: "\x1b[2m",
|
|
58
|
+
underscore: "\x1b[4m",
|
|
59
|
+
blink: "\x1b[5m",
|
|
60
|
+
reverse: "\x1b[7m",
|
|
61
|
+
hidden: "\x1b[8m",
|
|
62
|
+
fg: {
|
|
63
|
+
black: "\x1b[30m",
|
|
64
|
+
red: "\x1b[31m",
|
|
65
|
+
green: "\x1b[32m",
|
|
66
|
+
yellow: "\x1b[33m",
|
|
67
|
+
blue: "\x1b[34m",
|
|
68
|
+
magenta: "\x1b[35m",
|
|
69
|
+
cyan: "\x1b[36m",
|
|
70
|
+
white: "\x1b[37m",
|
|
71
|
+
},
|
|
72
|
+
bg: {
|
|
73
|
+
black: "\x1b[40m",
|
|
74
|
+
red: "\x1b[41m",
|
|
75
|
+
green: "\x1b[42m",
|
|
76
|
+
yellow: "\x1b[43m",
|
|
77
|
+
blue: "\x1b[44m",
|
|
78
|
+
magenta: "\x1b[45m",
|
|
79
|
+
cyan: "\x1b[46m",
|
|
80
|
+
white: "\x1b[47m",
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
function logError(message) {
|
|
84
|
+
console.log("".concat(colors.bright).concat(colors.fg.red, "[Error]:").concat(colors.reset, " ").concat(message));
|
|
85
|
+
}
|
|
86
|
+
function logSuccess(message) {
|
|
87
|
+
console.log("".concat(colors.bright).concat(colors.fg.green, "[Successful]:").concat(colors.reset, " ").concat(message));
|
|
88
|
+
}
|
|
89
|
+
function logWarning(message) {
|
|
90
|
+
console.log("".concat(colors.bright).concat(colors.fg.yellow, "[Warning]:").concat(colors.reset, " ").concat(message));
|
|
91
|
+
}
|
|
92
|
+
function logInfo(message) {
|
|
93
|
+
console.log("".concat(colors.bright).concat(colors.fg.blue, "[Info]:").concat(colors.reset, " ").concat(message));
|
|
79
94
|
}
|
|
80
95
|
function starter(client, options) {
|
|
81
96
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -88,16 +103,17 @@ function starter(client, options) {
|
|
|
88
103
|
case 0:
|
|
89
104
|
_g.trys.push([0, 3, , 4]);
|
|
90
105
|
if (!client) {
|
|
91
|
-
throw new Error(
|
|
106
|
+
throw new Error("\x1b[31mMissing client parameter. Please provide a valid Discord client.\x1b[0m");
|
|
92
107
|
}
|
|
93
108
|
if (!options.token) return [3 /*break*/, 2];
|
|
94
|
-
return [4 /*yield*/, client
|
|
109
|
+
return [4 /*yield*/, client
|
|
110
|
+
.login(options.token)
|
|
95
111
|
.then(function () {
|
|
96
112
|
var _a;
|
|
97
|
-
|
|
113
|
+
logSuccess("Bot ".concat((_a = client.user) === null || _a === void 0 ? void 0 : _a.tag, " is online! "));
|
|
98
114
|
})
|
|
99
115
|
.catch(function (error) {
|
|
100
|
-
|
|
116
|
+
logError("Invalid token provided. Please provide a valid bot token");
|
|
101
117
|
process.exit(1);
|
|
102
118
|
})];
|
|
103
119
|
case 1:
|
|
@@ -108,7 +124,7 @@ function starter(client, options) {
|
|
|
108
124
|
slash: ((_a = options.slashCommandPath) === null || _a === void 0 ? void 0 : _a.logsId) || null,
|
|
109
125
|
prefix: ((_b = options.prefixCommandPath) === null || _b === void 0 ? void 0 : _b.logsId) || null,
|
|
110
126
|
};
|
|
111
|
-
client.on(
|
|
127
|
+
client.on("ready", function () { return __awaiter(_this, void 0, void 0, function () {
|
|
112
128
|
var error_2, presenceOptions, path, dir, gId, gl, slashCommands, avatarData, response, _a, _b, _c, prefix, error_3;
|
|
113
129
|
var _d, _e;
|
|
114
130
|
var _f, _g, _h, _j;
|
|
@@ -122,9 +138,9 @@ function starter(client, options) {
|
|
|
122
138
|
if (!options.lavalink.nodes || options.lavalink.nodes.length === 0) {
|
|
123
139
|
options.lavalink.nodes = [
|
|
124
140
|
{
|
|
125
|
-
host:
|
|
141
|
+
host: "195.58.58.23",
|
|
126
142
|
port: 25565,
|
|
127
|
-
password:
|
|
143
|
+
password: "best",
|
|
128
144
|
secure: false,
|
|
129
145
|
},
|
|
130
146
|
];
|
|
@@ -132,25 +148,25 @@ function starter(client, options) {
|
|
|
132
148
|
return [4 /*yield*/, client.riffy.init((_f = client === null || client === void 0 ? void 0 : client.user) === null || _f === void 0 ? void 0 : _f.id)];
|
|
133
149
|
case 2:
|
|
134
150
|
_k.sent();
|
|
135
|
-
|
|
151
|
+
logInfo("Lavalink has been initialized. Please wait we are trying to connect");
|
|
136
152
|
return [3 /*break*/, 5];
|
|
137
153
|
case 3:
|
|
138
154
|
error_2 = _k.sent();
|
|
139
|
-
|
|
155
|
+
logError("Failed to initialize Riffy: ".concat(error_2.message));
|
|
140
156
|
return [3 /*break*/, 5];
|
|
141
157
|
case 4:
|
|
142
|
-
|
|
158
|
+
logWarning("Before connecting please check your lavalink is v3/v4 to connect successfully.");
|
|
143
159
|
return [7 /*endfinally*/];
|
|
144
160
|
case 5:
|
|
145
161
|
if (!(options.status || options.name || options.type)) return [3 /*break*/, 7];
|
|
146
162
|
presenceOptions = {
|
|
147
163
|
activities: [
|
|
148
164
|
{
|
|
149
|
-
name: options.name ||
|
|
150
|
-
type: typeof options.type ===
|
|
165
|
+
name: options.name || "/help",
|
|
166
|
+
type: typeof options.type === "number" ? options.type : 2,
|
|
151
167
|
},
|
|
152
168
|
],
|
|
153
|
-
status: options.status ||
|
|
169
|
+
status: options.status || "idle",
|
|
154
170
|
};
|
|
155
171
|
return [4 /*yield*/, ((_g = client.user) === null || _g === void 0 ? void 0 : _g.setPresence(presenceOptions))];
|
|
156
172
|
case 6:
|
|
@@ -165,10 +181,10 @@ function starter(client, options) {
|
|
|
165
181
|
case 9:
|
|
166
182
|
if (!(options.slashCommandPath && options.slashCommandPath.path)) return [3 /*break*/, 12];
|
|
167
183
|
if (!options.slashCommandPath.baseDir) {
|
|
168
|
-
return [2 /*return*/,
|
|
184
|
+
return [2 /*return*/, logWarning("Please provide a baseDir. Type in options for slash (baseDir: __dirname).")];
|
|
169
185
|
}
|
|
170
186
|
if (!options.token) {
|
|
171
|
-
throw new Error(
|
|
187
|
+
throw new Error("Error: No token is being provided in options.");
|
|
172
188
|
}
|
|
173
189
|
path = options.slashCommandPath.path;
|
|
174
190
|
dir = options.slashCommandPath.baseDir;
|
|
@@ -184,13 +200,13 @@ function starter(client, options) {
|
|
|
184
200
|
case 12:
|
|
185
201
|
if (!options.botAvatar) return [3 /*break*/, 18];
|
|
186
202
|
avatarData = void 0;
|
|
187
|
-
if (!options.botAvatar.startsWith(
|
|
188
|
-
return [4 /*yield*/,
|
|
189
|
-
responseType:
|
|
203
|
+
if (!options.botAvatar.startsWith("http")) return [3 /*break*/, 14];
|
|
204
|
+
return [4 /*yield*/, axios_1.get(options.botAvatar, {
|
|
205
|
+
responseType: "arraybuffer",
|
|
190
206
|
})];
|
|
191
207
|
case 13:
|
|
192
208
|
response = _k.sent();
|
|
193
|
-
avatarData = Buffer.from(response.data,
|
|
209
|
+
avatarData = Buffer.from(response.data, "binary");
|
|
194
210
|
return [3 /*break*/, 16];
|
|
195
211
|
case 14: return [4 /*yield*/, fs_1.promises.readFile(options.botAvatar)];
|
|
196
212
|
case 15:
|
|
@@ -220,7 +236,7 @@ function starter(client, options) {
|
|
|
220
236
|
_k.label = 23;
|
|
221
237
|
case 23:
|
|
222
238
|
if (!(options.prefixCommandPath && options.prefixCommandPath.path)) return [3 /*break*/, 25];
|
|
223
|
-
prefix = options.prefix ||
|
|
239
|
+
prefix = options.prefixCommandPath.prefix || "!";
|
|
224
240
|
return [4 /*yield*/, (0, prefixRegister_1.readCommands)(client, options.prefixCommandPath.path)];
|
|
225
241
|
case 24:
|
|
226
242
|
_k.sent();
|
|
@@ -234,11 +250,11 @@ function starter(client, options) {
|
|
|
234
250
|
_k.label = 26;
|
|
235
251
|
case 26:
|
|
236
252
|
_k.trys.push([26, 30, , 31]);
|
|
237
|
-
return [4 /*yield*/, (0, mongoConnect)(options.mongo.mongoURI, options.mongo.dataName)];
|
|
253
|
+
return [4 /*yield*/, (0, utils_1.mongoConnect)(options.mongo.mongoURI, options.mongo.dataName)];
|
|
238
254
|
case 27:
|
|
239
255
|
_k.sent();
|
|
240
256
|
if (!(options.mongo.initialize === true)) return [3 /*break*/, 29];
|
|
241
|
-
return [4 /*yield*/, (0, initializeDb)(20000)];
|
|
257
|
+
return [4 /*yield*/, (0, utils_1.initializeDb)(20000)];
|
|
242
258
|
case 28:
|
|
243
259
|
_k.sent();
|
|
244
260
|
_k.label = 29;
|
|
@@ -253,8 +269,8 @@ function starter(client, options) {
|
|
|
253
269
|
}); });
|
|
254
270
|
if (options.webView) {
|
|
255
271
|
port_1 = options.webView.port || 3000;
|
|
256
|
-
hostname_1 = options.webView.hostname ||
|
|
257
|
-
app = (0,
|
|
272
|
+
hostname_1 = options.webView.hostname || "localhost";
|
|
273
|
+
app = (0, express_1)();
|
|
258
274
|
if (options.webView.middleware) {
|
|
259
275
|
options.webView.middleware(app);
|
|
260
276
|
}
|
|
@@ -262,8 +278,8 @@ function starter(client, options) {
|
|
|
262
278
|
options.webView.routes(app);
|
|
263
279
|
}
|
|
264
280
|
else {
|
|
265
|
-
app.get(
|
|
266
|
-
res.send(
|
|
281
|
+
app.get("/", function (req, res) {
|
|
282
|
+
res.send("Hello, this is a simple web server!");
|
|
267
283
|
});
|
|
268
284
|
}
|
|
269
285
|
app.listen(port_1, hostname_1, function () {
|
|
@@ -275,15 +291,15 @@ function starter(client, options) {
|
|
|
275
291
|
if (nodes.length === 0) {
|
|
276
292
|
nodes = [
|
|
277
293
|
{
|
|
278
|
-
host:
|
|
294
|
+
host: "195.58.58.23",
|
|
279
295
|
port: 25565,
|
|
280
|
-
password:
|
|
296
|
+
password: "best",
|
|
281
297
|
secure: false,
|
|
282
298
|
},
|
|
283
299
|
];
|
|
284
300
|
}
|
|
285
|
-
searchPlateForm = ((_c = options.lavalink) === null || _c === void 0 ? void 0 : _c.search) ||
|
|
286
|
-
restVersion = ((_d = options.lavalink) === null || _d === void 0 ? void 0 : _d.version) ||
|
|
301
|
+
searchPlateForm = ((_c = options.lavalink) === null || _c === void 0 ? void 0 : _c.search) || "ytmsearch";
|
|
302
|
+
restVersion = ((_d = options.lavalink) === null || _d === void 0 ? void 0 : _d.version) || "v4";
|
|
287
303
|
client.riffy = new riffy_1.Riffy(client, nodes, {
|
|
288
304
|
send: function (payload) {
|
|
289
305
|
var guild = client.guilds.cache.get(payload.d.guild_id);
|
|
@@ -294,10 +310,10 @@ function starter(client, options) {
|
|
|
294
310
|
restVersion: restVersion,
|
|
295
311
|
});
|
|
296
312
|
client.restVersion = restVersion;
|
|
297
|
-
client.riffy.on(
|
|
298
|
-
|
|
313
|
+
client.riffy.on("nodeConnect", function (node) {
|
|
314
|
+
logSuccess("Node \"".concat(node.name, "\" connected."));
|
|
299
315
|
});
|
|
300
|
-
client.riffy.on(
|
|
316
|
+
client.riffy.on("trackStart", function (player, track) { return __awaiter(_this, void 0, void 0, function () {
|
|
301
317
|
return __generator(this, function (_a) {
|
|
302
318
|
switch (_a.label) {
|
|
303
319
|
case 0: return [4 /*yield*/, (0, start_1.handleTrackStart)(client, player, track)];
|
|
@@ -307,7 +323,7 @@ function starter(client, options) {
|
|
|
307
323
|
}
|
|
308
324
|
});
|
|
309
325
|
}); });
|
|
310
|
-
client.riffy.on(
|
|
326
|
+
client.riffy.on("queueEnd", function (player) { return __awaiter(_this, void 0, void 0, function () {
|
|
311
327
|
return __generator(this, function (_a) {
|
|
312
328
|
switch (_a.label) {
|
|
313
329
|
case 0: return [4 /*yield*/, (0, end_1.handleQueueEnd)(client, player)];
|
|
@@ -317,7 +333,7 @@ function starter(client, options) {
|
|
|
317
333
|
}
|
|
318
334
|
});
|
|
319
335
|
}); });
|
|
320
|
-
client.on(
|
|
336
|
+
client.on("interactionCreate", function (interaction) { return __awaiter(_this, void 0, void 0, function () {
|
|
321
337
|
return __generator(this, function (_a) {
|
|
322
338
|
if (interaction.isButton()) {
|
|
323
339
|
(0, buttons_1.handleButtonInteraction)(interaction);
|
|
@@ -325,7 +341,7 @@ function starter(client, options) {
|
|
|
325
341
|
return [2 /*return*/];
|
|
326
342
|
});
|
|
327
343
|
}); });
|
|
328
|
-
client.on(
|
|
344
|
+
client.on("raw", function (d) {
|
|
329
345
|
if (![
|
|
330
346
|
discord_js_1.GatewayDispatchEvents.VoiceStateUpdate,
|
|
331
347
|
discord_js_1.GatewayDispatchEvents.VoiceServerUpdate,
|
|
@@ -337,30 +353,35 @@ function starter(client, options) {
|
|
|
337
353
|
return [3 /*break*/, 4];
|
|
338
354
|
case 3:
|
|
339
355
|
error_1 = _g.sent();
|
|
340
|
-
|
|
356
|
+
logError("Error in start function: ".concat(error_1.message));
|
|
341
357
|
return [3 /*break*/, 4];
|
|
342
358
|
case 4:
|
|
343
359
|
if ((_e = options.antiCrash) === null || _e === void 0 ? void 0 : _e.enabled) {
|
|
344
|
-
process.on(
|
|
360
|
+
process.on("uncaughtException", function (error, origin) { return __awaiter(_this, void 0, void 0, function () {
|
|
345
361
|
var fileNameMatch, fileName, embed, error_4;
|
|
346
362
|
var _a, _b, _c, _d;
|
|
347
363
|
return __generator(this, function (_e) {
|
|
348
364
|
switch (_e.label) {
|
|
349
365
|
case 0:
|
|
350
366
|
fileNameMatch = (_a = error.stack) === null || _a === void 0 ? void 0 : _a.match(/at .* \((.*):\d+:\d+\)/);
|
|
351
|
-
fileName = fileNameMatch ? fileNameMatch[1] :
|
|
352
|
-
console.error(
|
|
367
|
+
fileName = fileNameMatch ? fileNameMatch[1] : "Unknown File";
|
|
368
|
+
console.error("Uncaught exception:", error, "origin:", origin);
|
|
353
369
|
if (!((_b = options.antiCrash) === null || _b === void 0 ? void 0 : _b.webhookURL)) return [3 /*break*/, 4];
|
|
354
370
|
_e.label = 1;
|
|
355
371
|
case 1:
|
|
356
372
|
_e.trys.push([1, 3, , 4]);
|
|
357
|
-
webhookClient_1 = new discord_js_1.WebhookClient({
|
|
373
|
+
webhookClient_1 = new discord_js_1.WebhookClient({
|
|
374
|
+
url: (_c = options.antiCrash) === null || _c === void 0 ? void 0 : _c.webhookURL,
|
|
375
|
+
});
|
|
358
376
|
embed = new discord_js_1.EmbedBuilder()
|
|
359
|
-
.setTitle(
|
|
377
|
+
.setTitle("Uncaught Exception Monitor")
|
|
360
378
|
.setDescription("**File:** `".concat(fileName, "`\n**Error:** `").concat(error.message, "`\n**Stack Trace:** ```").concat(error.stack, "```"))
|
|
361
|
-
.setColor(
|
|
379
|
+
.setColor("Red")
|
|
362
380
|
.setTimestamp();
|
|
363
|
-
return [4 /*yield*/, webhookClient_1.send({
|
|
381
|
+
return [4 /*yield*/, webhookClient_1.send({
|
|
382
|
+
content: "<@".concat(((_d = options.antiCrash) === null || _d === void 0 ? void 0 : _d.userToMention) || "", ">"),
|
|
383
|
+
embeds: [embed],
|
|
384
|
+
})];
|
|
364
385
|
case 2:
|
|
365
386
|
_e.sent();
|
|
366
387
|
return [3 /*break*/, 4];
|
|
@@ -372,26 +393,31 @@ function starter(client, options) {
|
|
|
372
393
|
}
|
|
373
394
|
});
|
|
374
395
|
}); });
|
|
375
|
-
process.on(
|
|
396
|
+
process.on("uncaughtExceptionMonitor", function (err, origin) { return __awaiter(_this, void 0, void 0, function () {
|
|
376
397
|
var fileNameMatch, fileName, embed, error_5;
|
|
377
398
|
var _a, _b, _c, _d;
|
|
378
399
|
return __generator(this, function (_e) {
|
|
379
400
|
switch (_e.label) {
|
|
380
401
|
case 0:
|
|
381
|
-
console.error(
|
|
402
|
+
console.error("Uncaught exception monitored:", err, "origin:", origin);
|
|
382
403
|
fileNameMatch = (_a = err.stack) === null || _a === void 0 ? void 0 : _a.match(/at .* \((.*):\d+:\d+\)/);
|
|
383
|
-
fileName = fileNameMatch ? fileNameMatch[1] :
|
|
404
|
+
fileName = fileNameMatch ? fileNameMatch[1] : "Unknown File";
|
|
384
405
|
if (!((_b = options.antiCrash) === null || _b === void 0 ? void 0 : _b.webhookURL)) return [3 /*break*/, 4];
|
|
385
406
|
_e.label = 1;
|
|
386
407
|
case 1:
|
|
387
408
|
_e.trys.push([1, 3, , 4]);
|
|
388
|
-
webhookClient_1 = new discord_js_1.WebhookClient({
|
|
409
|
+
webhookClient_1 = new discord_js_1.WebhookClient({
|
|
410
|
+
url: (_c = options.antiCrash) === null || _c === void 0 ? void 0 : _c.webhookURL,
|
|
411
|
+
});
|
|
389
412
|
embed = new discord_js_1.EmbedBuilder()
|
|
390
|
-
.setTitle(
|
|
413
|
+
.setTitle("Uncaught Exception Monitor")
|
|
391
414
|
.setDescription("**File:** `".concat(fileName, "`\n**Error:** `").concat(err.message, "`\n**Stack Trace:** ```").concat(err.stack, "```"))
|
|
392
|
-
.setColor(
|
|
415
|
+
.setColor("Red")
|
|
393
416
|
.setTimestamp();
|
|
394
|
-
return [4 /*yield*/, webhookClient_1.send({
|
|
417
|
+
return [4 /*yield*/, webhookClient_1.send({
|
|
418
|
+
content: "<@".concat(((_d = options.antiCrash) === null || _d === void 0 ? void 0 : _d.userToMention) || "", ">"),
|
|
419
|
+
embeds: [embed],
|
|
420
|
+
})];
|
|
395
421
|
case 2:
|
|
396
422
|
_e.sent();
|
|
397
423
|
return [3 /*break*/, 4];
|
|
@@ -412,4 +438,4 @@ function starter(client, options) {
|
|
|
412
438
|
});
|
|
413
439
|
});
|
|
414
440
|
}
|
|
415
|
-
exports.starter = starter;
|
|
441
|
+
exports.starter = starter;
|