apexify.js 2.3.4 → 2.3.5

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