apexify.js 2.3.4 → 2.3.6

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.
package/README.md CHANGED
@@ -43,6 +43,7 @@ const options = {
43
43
  type: 0, // type is for activity (Playing, Watching, Custom , Listening, etc.)
44
44
  botName: 'tools', // bot name
45
45
  botAvatar: './pfp.jpeg', // set your bot avatar as a URL or local file (GIF also works)
46
+ botBanner: 'url or path', // set your bot banner
46
47
  eventsPath,
47
48
 
48
49
  // Note: Don't provide guildId or put it in the options if you set global as true
@@ -44,13 +44,14 @@ 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 mongoDB_1 = require("../../database/MongoDB");
47
+ var { mongoConnect, initializeDb} = require("../../database/MongoDB");
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
51
  var axios_1 = require("axios");
52
52
  var fs_1 = require("fs");
53
53
  var express_1 = require("express");
54
+ const { mongoConnect } = require("../../database/MongoDB");
54
55
  function typeSentence(sentence, speed) {
55
56
  return __awaiter(this, void 0, void 0, function () {
56
57
  var _i, sentence_1, char;
@@ -109,15 +110,16 @@ function starter(client, options) {
109
110
  prefix: ((_b = options.prefixCommandPath) === null || _b === void 0 ? void 0 : _b.logsId) || null,
110
111
  };
111
112
  client.on('ready', function () { return __awaiter(_this, void 0, void 0, function () {
112
- var error_2, presenceOptions, path, dir, gId, gl, slashCommands, avatarData, response, prefix, error_3;
113
- var _a, _b, _c, _d;
114
- return __generator(this, function (_e) {
115
- switch (_e.label) {
113
+ var error_2, presenceOptions, path, dir, gId, gl, slashCommands, avatarData, response, _a, _b, _c, prefix, error_3;
114
+ var _d, _e;
115
+ var _f, _g, _h, _j;
116
+ return __generator(this, function (_k) {
117
+ switch (_k.label) {
116
118
  case 0:
117
119
  if (!options.lavalink) return [3 /*break*/, 5];
118
- _e.label = 1;
120
+ _k.label = 1;
119
121
  case 1:
120
- _e.trys.push([1, 3, 4, 5]);
122
+ _k.trys.push([1, 3, 4, 5]);
121
123
  if (!options.lavalink.nodes || options.lavalink.nodes.length === 0) {
122
124
  options.lavalink.nodes = [
123
125
  {
@@ -128,13 +130,13 @@ function starter(client, options) {
128
130
  },
129
131
  ];
130
132
  }
131
- return [4 /*yield*/, client.riffy.init((_a = client === null || client === void 0 ? void 0 : client.user) === null || _a === void 0 ? void 0 : _a.id)];
133
+ return [4 /*yield*/, client.riffy.init((_f = client === null || client === void 0 ? void 0 : client.user) === null || _f === void 0 ? void 0 : _f.id)];
132
134
  case 2:
133
- _e.sent();
135
+ _k.sent();
134
136
  typeSentence("Lavalink has been initialized. Please wait we are trying to connect", 50);
135
137
  return [3 /*break*/, 5];
136
138
  case 3:
137
- error_2 = _e.sent();
139
+ error_2 = _k.sent();
138
140
  console.error("Failed to initialize Riffy: ".concat(error_2.message));
139
141
  return [3 /*break*/, 5];
140
142
  case 4:
@@ -151,17 +153,16 @@ function starter(client, options) {
151
153
  ],
152
154
  status: options.status || 'idle',
153
155
  };
154
-
155
- return [4 /*yield*/, ((_b = client.user) === null || _b === void 0 ? void 0 : _b.setPresence(presenceOptions))];
156
+ return [4 /*yield*/, ((_g = client.user) === null || _g === void 0 ? void 0 : _g.setPresence(presenceOptions))];
156
157
  case 6:
157
- _e.sent();
158
- _e.label = 7;
158
+ _k.sent();
159
+ _k.label = 7;
159
160
  case 7:
160
161
  if (!options.eventsPath) return [3 /*break*/, 9];
161
162
  return [4 /*yield*/, (0, eventer_1.registerEvents)(client, options.eventsPath)];
162
163
  case 8:
163
- _e.sent();
164
- _e.label = 9;
164
+ _k.sent();
165
+ _k.label = 9;
165
166
  case 9:
166
167
  if (!(options.slashCommandPath && options.slashCommandPath.path)) return [3 /*break*/, 12];
167
168
  if (!options.slashCommandPath.baseDir) {
@@ -176,11 +177,11 @@ function starter(client, options) {
176
177
  gl = options.slashCommandPath.global;
177
178
  return [4 /*yield*/, (0, slashRegister_1.registerSlashCommands)(client, options.token, path, dir, gId, gl)];
178
179
  case 10:
179
- slashCommands = _e.sent();
180
+ slashCommands = _k.sent();
180
181
  return [4 /*yield*/, (0, slashResponder_1.slashRespond)(client, slashCommands, logChannels_1.slash)];
181
182
  case 11:
182
- _e.sent();
183
- _e.label = 12;
183
+ _k.sent();
184
+ _k.label = 12;
184
185
  case 12:
185
186
  if (!options.botAvatar) return [3 /*break*/, 18];
186
187
  avatarData = void 0;
@@ -189,53 +190,65 @@ function starter(client, options) {
189
190
  responseType: 'arraybuffer',
190
191
  })];
191
192
  case 13:
192
- response = _e.sent();
193
+ response = _k.sent();
193
194
  avatarData = Buffer.from(response.data, 'binary');
194
195
  return [3 /*break*/, 16];
195
196
  case 14: return [4 /*yield*/, fs_1.promises.readFile(options.botAvatar)];
196
197
  case 15:
197
- avatarData = _e.sent();
198
- _e.label = 16;
199
- case 16: return [4 /*yield*/, ((_c = client.user) === null || _c === void 0 ? void 0 : _c.setAvatar(avatarData))];
198
+ avatarData = _k.sent();
199
+ _k.label = 16;
200
+ case 16: return [4 /*yield*/, ((_h = client.user) === null || _h === void 0 ? void 0 : _h.setAvatar(avatarData))];
200
201
  case 17:
201
- _e.sent();
202
- _e.label = 18;
202
+ _k.sent();
203
+ _k.label = 18;
203
204
  case 18:
204
205
  if (!options.botName) return [3 /*break*/, 20];
205
- return [4 /*yield*/, ((_d = client.user) === null || _d === void 0 ? void 0 : _d.setUsername(options.botName))];
206
+ return [4 /*yield*/, ((_j = client.user) === null || _j === void 0 ? void 0 : _j.setUsername(options.botName))];
206
207
  case 19:
207
- _e.sent();
208
- _e.label = 20;
208
+ _k.sent();
209
+ _k.label = 20;
209
210
  case 20:
210
- if (!(options.prefixCommandPath && options.prefixCommandPath.path)) return [3 /*break*/, 22];
211
+ if (!options.botBanner) return [3 /*break*/, 23];
212
+ _b = (_a = client.rest).patch;
213
+ _c = [discord_js_1.Routes.user()];
214
+ _d = {};
215
+ _e = {};
216
+ return [4 /*yield*/, discord_js_1.DataResolver.resolveImage(options.botBanner)];
217
+ case 21: return [4 /*yield*/, _b.apply(_a, _c.concat([(_d.body = (_e.banner = _k.sent(), _e),
218
+ _d)]))];
219
+ case 22:
220
+ _k.sent();
221
+ _k.label = 23;
222
+ case 23:
223
+ if (!(options.prefixCommandPath && options.prefixCommandPath.path)) return [3 /*break*/, 25];
211
224
  prefix = options.prefix || '!';
212
225
  return [4 /*yield*/, (0, prefixRegister_1.readCommands)(client, options.prefixCommandPath.path)];
213
- case 21:
214
- _e.sent();
226
+ case 24:
227
+ _k.sent();
215
228
  (0, prefixResponder_1.prefixRespond)(client, prefix, logChannels_1.prefix);
216
- _e.label = 22;
217
- case 22:
218
- if (!(options.mongo && options.mongo.mongoURI && options.mongo.dataName)) return [3 /*break*/, 28];
229
+ _k.label = 25;
230
+ case 25:
231
+ if (!(options.mongo && options.mongo.mongoURI && options.mongo.dataName)) return [3 /*break*/, 31];
219
232
  if (!options.mongo.mongoURI || !options.mongo.dataName) {
220
233
  throw new Error("\u001B[31mYou need to provide mongoURI and Database name for a successful connection.\u001B[0m");
221
234
  }
222
- _e.label = 23;
223
- case 23:
224
- _e.trys.push([23, 27, , 28]);
225
- return [4 /*yield*/, (0, mongoDB_1.mongoConnect)(options.mongo.mongoURI, options.mongo.dataName)];
226
- case 24:
227
- _e.sent();
228
- if (!(options.mongo.initialize === true)) return [3 /*break*/, 26];
229
- return [4 /*yield*/, (0, mongoDB_1.initializeDb)(20000)];
230
- case 25:
231
- _e.sent();
232
- _e.label = 26;
233
- case 26: return [3 /*break*/, 28];
235
+ _k.label = 26;
236
+ case 26:
237
+ _k.trys.push([26, 30, , 31]);
238
+ return [4 /*yield*/, (0, utils_1.mongoConnect)(options.mongo.mongoURI, options.mongo.dataName)];
234
239
  case 27:
235
- error_3 = _e.sent();
240
+ _k.sent();
241
+ if (!(options.mongo.initialize === true)) return [3 /*break*/, 29];
242
+ return [4 /*yield*/, (0, utils_1.initializeDb)(20000)];
243
+ case 28:
244
+ _k.sent();
245
+ _k.label = 29;
246
+ case 29: return [3 /*break*/, 31];
247
+ case 30:
248
+ error_3 = _k.sent();
236
249
  console.warn("\u001B[1m\u001B[35m".concat(error_3, "\u001B[0m"));
237
- return [3 /*break*/, 28];
238
- case 28: return [2 /*return*/];
250
+ return [3 /*break*/, 31];
251
+ case 31: return [2 /*return*/];
239
252
  }
240
253
  });
241
254
  }); });
@@ -331,30 +344,29 @@ function starter(client, options) {
331
344
  if ((_e = options.antiCrash) === null || _e === void 0 ? void 0 : _e.enabled) {
332
345
  process.on('uncaughtException', function (error, origin) { return __awaiter(_this, void 0, void 0, function () {
333
346
  var fileNameMatch, fileName, embed, error_4;
334
- var _a, _b, _c, _d, _e;
335
- return __generator(this, function (_f) {
336
- switch (_f.label) {
347
+ var _a, _b, _c, _d;
348
+ return __generator(this, function (_e) {
349
+ switch (_e.label) {
337
350
  case 0:
338
351
  fileNameMatch = (_a = error.stack) === null || _a === void 0 ? void 0 : _a.match(/at .* \((.*):\d+:\d+\)/);
339
352
  fileName = fileNameMatch ? fileNameMatch[1] : 'Unknown File';
340
353
  console.error('Uncaught exception:', error, 'origin:', origin);
341
354
  if (!((_b = options.antiCrash) === null || _b === void 0 ? void 0 : _b.webhookURL)) return [3 /*break*/, 4];
342
- if (!((_c = options.antiCrash) === null || _c === void 0 ? void 0 : _c.webhookURL)) return [3 /*break*/, 4];
343
- _f.label = 1;
355
+ _e.label = 1;
344
356
  case 1:
345
- _f.trys.push([1, 3, , 4]);
346
- webhookClient_1 = new discord_js_1.WebhookClient({ url: (_d = options.antiCrash) === null || _d === void 0 ? void 0 : _d.webhookURL });
357
+ _e.trys.push([1, 3, , 4]);
358
+ webhookClient_1 = new discord_js_1.WebhookClient({ url: (_c = options.antiCrash) === null || _c === void 0 ? void 0 : _c.webhookURL });
347
359
  embed = new discord_js_1.EmbedBuilder()
348
360
  .setTitle('Uncaught Exception Monitor')
349
361
  .setDescription("**File:** `".concat(fileName, "`\n**Error:** `").concat(error.message, "`\n**Stack Trace:** ```").concat(error.stack, "```"))
350
362
  .setColor('Red')
351
363
  .setTimestamp();
352
- return [4 /*yield*/, webhookClient_1.send({ content: "<@".concat((_e = options.antiCrash) === null || _e === void 0 ? void 0 : _e.userToMention, ">"), embeds: [embed] })];
364
+ return [4 /*yield*/, webhookClient_1.send({ content: "<@".concat(((_d = options.antiCrash) === null || _d === void 0 ? void 0 : _d.userToMention) || '', ">"), embeds: [embed] })];
353
365
  case 2:
354
- _f.sent();
366
+ _e.sent();
355
367
  return [3 /*break*/, 4];
356
368
  case 3:
357
- error_4 = _f.sent();
369
+ error_4 = _e.sent();
358
370
  console.error(error_4.message);
359
371
  return [3 /*break*/, 4];
360
372
  case 4: return [2 /*return*/];
@@ -380,7 +392,7 @@ function starter(client, options) {
380
392
  .setDescription("**File:** `".concat(fileName, "`\n**Error:** `").concat(err.message, "`\n**Stack Trace:** ```").concat(err.stack, "```"))
381
393
  .setColor('Red')
382
394
  .setTimestamp();
383
- return [4 /*yield*/, webhookClient_1.send({ content: "<@".concat((_d = options.antiCrash) === null || _d === void 0 ? void 0 : _d.userToMention, ">"), embeds: [embed] })];
395
+ return [4 /*yield*/, webhookClient_1.send({ content: "<@".concat(((_d = options.antiCrash) === null || _d === void 0 ? void 0 : _d.userToMention) || '', ">"), embeds: [embed] })];
384
396
  case 2:
385
397
  _e.sent();
386
398
  return [3 /*break*/, 4];
@@ -401,5 +413,4 @@ function starter(client, options) {
401
413
  });
402
414
  });
403
415
  }
404
-
405
416
  exports.starter = starter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apexify.js",
3
- "version": "2.3.4",
3
+ "version": "2.3.6",
4
4
  "description": "Ai with Canvas and Database library. Supports typescript and javascript",
5
5
  "main": "index.js",
6
6
  "scripts": {
File without changes