apexify.js 2.4.4 → 3.0.0

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.
Files changed (71) hide show
  1. package/README.md +4 -710
  2. package/dataSQL/data.sql +5 -0
  3. package/dataSQL/dataName.sql +0 -0
  4. package/dataSQL/example_table.sql +1 -0
  5. package/index.js +3 -78
  6. package/lib/ai/apexAI.js +2 -2
  7. package/lib/{discord/events/handler → ai/buttons}/tools.js +1 -1
  8. package/lib/utils.js +2 -72
  9. package/package.json +2 -81
  10. package/lib/canvas/themes/level ara.ttf +0 -0
  11. package/lib/canvas/themes/levelFont.ttf +0 -0
  12. package/lib/canvas/themes/levels-card.js +0 -884
  13. package/lib/canvas/themes/music-card.js +0 -342
  14. package/lib/canvas/themes/numbers.ttf +0 -0
  15. package/lib/canvas/themes/tajawal.ttf +0 -0
  16. package/lib/database/MongoDB.js +0 -126
  17. package/lib/database/NanoDB.js +0 -1341
  18. package/lib/database/mongoDb/aggregate.js +0 -120
  19. package/lib/database/mongoDb/countDocs.js +0 -115
  20. package/lib/database/mongoDb/createCollection.js +0 -125
  21. package/lib/database/mongoDb/dataSize.js +0 -89
  22. package/lib/database/mongoDb/distinct.js +0 -110
  23. package/lib/database/mongoDb/drop.js +0 -76
  24. package/lib/database/mongoDb/find.js +0 -122
  25. package/lib/database/mongoDb/geoNear.js +0 -91
  26. package/lib/database/mongoDb/index.js +0 -71
  27. package/lib/database/mongoDb/listCollections.js +0 -81
  28. package/lib/database/mongoDb/migrateAndPrune.js +0 -89
  29. package/lib/database/mongoDb/migrateData.js +0 -79
  30. package/lib/database/mongoDb/remove.js +0 -73
  31. package/lib/database/mongoDb/removeMany.js +0 -73
  32. package/lib/database/mongoDb/removeManyExcept.js +0 -91
  33. package/lib/database/mongoDb/removeSpecific.js +0 -93
  34. package/lib/database/mongoDb/save.js +0 -94
  35. package/lib/database/mongoDb/searchMany.js +0 -109
  36. package/lib/database/mongoDb/textSearch.js +0 -88
  37. package/lib/database/mongoDb/updateAll.js +0 -80
  38. package/lib/database/mongoDb/updateAllExcept.js +0 -108
  39. package/lib/database/mongoDb/updateData.js +0 -106
  40. package/lib/database/nanoDb/fetchData.js +0 -39
  41. package/lib/database/nanoDb/removeField.js +0 -46
  42. package/lib/database/nanoDb/saveData.js +0 -68
  43. package/lib/database/nanoDb/updateFilter.js +0 -24
  44. package/lib/database/ready-schemas.js +0 -245
  45. package/lib/database/utils.js +0 -58
  46. package/lib/discord/discord-build/commands-(prefix)/music/functions/buttons.js +0 -361
  47. package/lib/discord/discord-build/commands-(prefix)/music/functions/end.js +0 -58
  48. package/lib/discord/discord-build/commands-(prefix)/music/functions/start.js +0 -115
  49. package/lib/discord/discord-build/commands-(prefix)/music/play.js +0 -152
  50. package/lib/discord/discord-build/commands-(prefix)/music/previous.js +0 -82
  51. package/lib/discord/discord-build/commands-(prefix)/music/resume.js +0 -93
  52. package/lib/discord/discord-build/commands-(prefix)/music/skip.js +0 -82
  53. package/lib/discord/discord-build/commands-(prefix)/music/stop.js +0 -79
  54. package/lib/discord/discord-build/components/buttons.js +0 -75
  55. package/lib/discord/discord-build/components/menus.js +0 -81
  56. package/lib/discord/discord-build/components/paginator.js +0 -156
  57. package/lib/discord/discord-build/components/permsChecker.js +0 -81
  58. package/lib/discord/discord-build/levelingSystem/cLevel.js +0 -829
  59. package/lib/discord/discord-build/levelingSystem/cLevelsArray.json +0 -104
  60. package/lib/discord/discord-build/utils.js +0 -23
  61. package/lib/discord/events/eventer.js +0 -145
  62. package/lib/discord/events/prefixRegister.js +0 -148
  63. package/lib/discord/events/prefixResponder.js +0 -163
  64. package/lib/discord/events/slashRegister.js +0 -183
  65. package/lib/discord/events/slashResponder.js +0 -108
  66. package/lib/discord/events/starter.js +0 -441
  67. package/lib/discord/functions/perms.js +0 -19
  68. package/lib/discord/utils.js +0 -6
  69. package/lib/general-functions/discord/typeWriter.js +0 -77
  70. package/lib/general-functions/utils.js +0 -19
  71. /package/lib/{discord/events/handler → ai/buttons}/drawMenu.js +0 -0
@@ -1,104 +0,0 @@
1
- {
2
- "levels": [
3
- { "level": 1, "xpCount": 5 },
4
- { "level": 2, "xpCount": 35 },
5
- { "level": 3, "xpCount": 70 },
6
- { "level": 4, "xpCount": 120 },
7
- { "level": 5, "xpCount": 160 },
8
- { "level": 6, "xpCount": 250 },
9
- { "level": 7, "xpCount": 450 },
10
- { "level": 8, "xpCount": 580 },
11
- { "level": 9, "xpCount": 700 },
12
- { "level": 10, "xpCount": 850 },
13
- { "level": 11, "xpCount": 1100 },
14
- { "level": 12, "xpCount": 1230 },
15
- { "level": 13, "xpCount": 1550 },
16
- { "level": 14, "xpCount": 1990 },
17
- { "level": 15, "xpCount": 2400 },
18
- { "level": 16, "xpCount": 2960 },
19
- { "level": 17, "xpCount": 3200 },
20
- { "level": 18, "xpCount": 3700 },
21
- { "level": 19, "xpCount": 4400 },
22
- { "level": 20, "xpCount": 5100 },
23
- { "level": 21, "xpCount": 6000 },
24
- { "level": 22, "xpCount": 6500 },
25
- { "level": 23, "xpCount": 7000 },
26
- { "level": 24, "xpCount": 7500 },
27
- { "level": 25, "xpCount": 8500 },
28
- { "level": 26, "xpCount": 9000 },
29
- { "level": 27, "xpCount": 10000 },
30
- { "level": 28, "xpCount": 11000 },
31
- { "level": 29, "xpCount": 12721 },
32
- { "level": 30, "xpCount": 15139 },
33
- { "level": 31, "xpCount": 17992 },
34
- { "level": 32, "xpCount": 19658 },
35
- { "level": 33, "xpCount": 22834 },
36
- { "level": 34, "xpCount": 26214 },
37
- { "level": 35, "xpCount": 29867 },
38
- { "level": 36, "xpCount": 31285 },
39
- { "level": 37, "xpCount": 35077 },
40
- { "level": 38, "xpCount": 37930 },
41
- { "level": 39, "xpCount": 39392 },
42
- { "level": 40, "xpCount": 41462 },
43
- { "level": 41, "xpCount": 386042 },
44
- { "level": 42, "xpCount": 509791 },
45
- { "level": 43, "xpCount": 673159 },
46
- { "level": 44, "xpCount": 888973 },
47
- { "level": 45, "xpCount": 1171859 },
48
- { "level": 46, "xpCount": 1549951 },
49
- { "level": 47, "xpCount": 2040932 },
50
- { "level": 48, "xpCount": 2695038 },
51
- { "level": 49, "xpCount": 3550620 },
52
- { "level": 50, "xpCount": 4684824 },
53
- { "level": 51, "xpCount": 6170044 },
54
- { "level": 52, "xpCount": 8139660 },
55
- { "level": 53, "xpCount": 10734397 },
56
- { "level": 54, "xpCount": 14182276 },
57
- { "level": 55, "xpCount": 18724096 },
58
- { "level": 56, "xpCount": 24688718 },
59
- { "level": 57, "xpCount": 32507416 },
60
- { "level": 58, "xpCount": 42823163 },
61
- { "level": 59, "xpCount": 56414589 },
62
- { "level": 60, "xpCount": 74362465 },
63
- { "level": 61, "xpCount": 97860082 },
64
- { "level": 62, "xpCount": 128817913 },
65
- { "level": 63, "xpCount": 169538018 },
66
- { "level": 64, "xpCount": 223183640 },
67
- { "level": 65, "xpCount": 293721316 },
68
- { "level": 66, "xpCount": 386179802 },
69
- { "level": 67, "xpCount": 508241182 },
70
- { "level": 68, "xpCount": 669978018 },
71
- { "level": 69, "xpCount": 882374543 },
72
- { "level": 70, "xpCount": 1161368550 },
73
- { "level": 71, "xpCount": 1531485816 },
74
- { "level": 72, "xpCount": 2019363479 },
75
- { "level": 73, "xpCount": 2652177185 },
76
- { "level": 74, "xpCount": 3492991382 },
77
- { "level": 75, "xpCount": 4592679630 },
78
- { "level": 76, "xpCount": 6042863577 },
79
- { "level": 77, "xpCount": 7950001230 },
80
- { "level": 78, "xpCount": 10455961833 },
81
- { "level": 79, "xpCount": 13767015363 },
82
- { "level": 80, "xpCount": 18110405603 },
83
- { "level": 81, "xpCount": 23831553791 },
84
- { "level": 82, "xpCount": 31379404535 },
85
- { "level": 83, "xpCount": 41228186516 },
86
- { "level": 84, "xpCount": 54114647132 },
87
- { "level": 85, "xpCount": 71165612795 },
88
- { "level": 86, "xpCount": 93612176697 },
89
- { "level": 87, "xpCount": 123144743489 },
90
- { "level": 88, "xpCount": 161918299863 },
91
- { "level": 89, "xpCount": 213044819774 },
92
- { "level": 90, "xpCount": 280457086297 },
93
- { "level": 91, "xpCount": 368724739110 },
94
- { "level": 92, "xpCount": 484779554948 },
95
- { "level": 93, "xpCount": 637901156038 },
96
- { "level": 94, "xpCount": 839170872646 },
97
- { "level": 95, "xpCount": 1104273070408 },
98
- { "level": 96, "xpCount": 1452123676651 },
99
- { "level": 97, "xpCount": 1909411703358 },
100
- { "level": 98, "xpCount": 2510815300675 },
101
- { "level": 99, "xpCount": 3305923134789 },
102
- { "level": 100, "xpCount": 4341405718094 }
103
- ]
104
- }
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LevelingSystem = exports.previousCommand = exports.resumeCommand = exports.skipCommand = exports.stopCommand = exports.playCommand = exports.PermissionChecker = exports.Paginator = exports.SelectMenuManager = exports.ButtonManager = void 0;
4
- var buttons_1 = require("./components/buttons");
5
- Object.defineProperty(exports, "ButtonManager", { enumerable: true, get: function () { return buttons_1.ButtonManager; } });
6
- var menus_1 = require("./components/menus");
7
- Object.defineProperty(exports, "SelectMenuManager", { enumerable: true, get: function () { return menus_1.SelectMenuManager; } });
8
- var paginator_1 = require("./components/paginator");
9
- Object.defineProperty(exports, "Paginator", { enumerable: true, get: function () { return paginator_1.Paginator; } });
10
- var permsChecker_1 = require("./components/permsChecker");
11
- Object.defineProperty(exports, "PermissionChecker", { enumerable: true, get: function () { return permsChecker_1.PermissionChecker; } });
12
- var play_1 = require("./commands-(prefix)/music/play");
13
- Object.defineProperty(exports, "playCommand", { enumerable: true, get: function () { return play_1.playCommand; } });
14
- var stop_1 = require("./commands-(prefix)/music/stop");
15
- Object.defineProperty(exports, "stopCommand", { enumerable: true, get: function () { return stop_1.stopCommand; } });
16
- var skip_1 = require("./commands-(prefix)/music/skip");
17
- Object.defineProperty(exports, "skipCommand", { enumerable: true, get: function () { return skip_1.skipCommand; } });
18
- var resume_1 = require("./commands-(prefix)/music/resume");
19
- Object.defineProperty(exports, "resumeCommand", { enumerable: true, get: function () { return resume_1.resumeCommand; } });
20
- var previous_1 = require("./commands-(prefix)/music/previous");
21
- Object.defineProperty(exports, "previousCommand", { enumerable: true, get: function () { return previous_1.previousCommand; } });
22
- var levelSystem = require("./levelingSystem/cLevel");
23
- Object.defineProperty(exports, "LevelingSystem", { enumerable: true, get: function () { return levelSystem.LevelingSystem; } });
@@ -1,145 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
39
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
40
- if (ar || !(i in from)) {
41
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
42
- ar[i] = from[i];
43
- }
44
- }
45
- return to.concat(ar || Array.prototype.slice.call(from));
46
- };
47
- Object.defineProperty(exports, "__esModule", { value: true });
48
- exports.registerEvents = void 0;
49
- var fs_1 = require("fs");
50
- var path_1 = require("path");
51
- var AsciiTable = require('ascii-table');
52
- function registerEvents(client, eventsFolderPath) {
53
- return __awaiter(this, void 0, void 0, function () {
54
- function processEventFile(filePath) {
55
- return __awaiter(this, void 0, void 0, function () {
56
- var stats, filesInDirectory, _i, filesInDirectory_1, item, itemPath, event_1, error_2;
57
- return __generator(this, function (_a) {
58
- switch (_a.label) {
59
- case 0:
60
- _a.trys.push([0, 8, , 9]);
61
- stats = (0, fs_1.statSync)(filePath);
62
- if (!stats.isDirectory()) return [3 /*break*/, 5];
63
- filesInDirectory = (0, fs_1.readdirSync)(filePath);
64
- if (filesInDirectory.length === 0) {
65
- return [2 /*return*/];
66
- }
67
- _i = 0, filesInDirectory_1 = filesInDirectory;
68
- _a.label = 1;
69
- case 1:
70
- if (!(_i < filesInDirectory_1.length)) return [3 /*break*/, 4];
71
- item = filesInDirectory_1[_i];
72
- itemPath = path_1.join(filePath, item);
73
- return [4 /*yield*/, processEventFile(itemPath)];
74
- case 2:
75
- _a.sent();
76
- _a.label = 3;
77
- case 3:
78
- _i++;
79
- return [3 /*break*/, 1];
80
- case 4: return [3 /*break*/, 7];
81
- case 5:
82
- if (!(stats.isFile() && filePath.endsWith('.js'))) return [3 /*break*/, 7];
83
- return [4 /*yield*/, Promise.resolve("".concat(filePath)).then(function (s) { return require(s); })];
84
- case 6:
85
- event_1 = _a.sent();
86
- if (event_1.once) {
87
- client.once(event_1.name, function () {
88
- var args = [];
89
- for (var _i = 0; _i < arguments.length; _i++) {
90
- args[_i] = arguments[_i];
91
- }
92
- return event_1.execute.apply(event_1, __spreadArray(__spreadArray([], args, false), [client], false));
93
- });
94
- }
95
- else {
96
- client.on(event_1.name, function () {
97
- var args = [];
98
- for (var _i = 0; _i < arguments.length; _i++) {
99
- args[_i] = arguments[_i];
100
- }
101
- return event_1.execute.apply(event_1, __spreadArray(__spreadArray([], args, false), [client], false));
102
- });
103
- }
104
- table.addRow(path_1.relative(eventsFolderPath, filePath), '🟢 Working');
105
- return [3 /*break*/, 7];
106
- case 7: return [3 /*break*/, 9];
107
- case 8:
108
- error_2 = _a.sent();
109
- console.error('\x1b[31m%s\x1b[0m', "Error in event file: ".concat(filePath));
110
- console.error('\x1b[31m%s\x1b[0m', error_2);
111
- table.addRow(path_1.relative(eventsFolderPath, filePath), '🔴 Broke');
112
- return [3 /*break*/, 9];
113
- case 9: return [2 /*return*/];
114
- }
115
- });
116
- });
117
- }
118
- var table, error_1, tableString;
119
- return __generator(this, function (_a) {
120
- switch (_a.label) {
121
- case 0:
122
- table = new AsciiTable('\x1b[33m Event Folders \x1b[0m');
123
- table.setHeading('Files', 'Status');
124
- _a.label = 1;
125
- case 1:
126
- _a.trys.push([1, 3, , 4]);
127
- return [4 /*yield*/, processEventFile(eventsFolderPath)];
128
- case 2:
129
- _a.sent();
130
- return [3 /*break*/, 4];
131
- case 3:
132
- error_1 = _a.sent();
133
- console.error('\x1b[31m%s\x1b[0m', "Error while processing events folder: ".concat(eventsFolderPath));
134
- console.error('\x1b[31m%s\x1b[0m', error_1);
135
- return [3 /*break*/, 4];
136
- case 4:
137
- tableString = table.toString();
138
- console.log(tableString.trim());
139
- return [2 /*return*/];
140
- }
141
- });
142
- });
143
- }
144
-
145
- exports.registerEvents = registerEvents;
@@ -1,148 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.commandNames = exports.aliases = exports.commands = exports.readCommands = void 0;
40
- var discord_js_1 = require("discord.js");
41
- var path_1 = require("path");
42
- var fs_1 = require("fs");
43
- var AsciiTable = require("ascii-table");
44
- var commands = new discord_js_1.Collection();
45
- exports.commands = commands;
46
- var aliases = new discord_js_1.Collection();
47
- exports.aliases = aliases;
48
- var commandNames = new Set();
49
- exports.commandNames = commandNames;
50
- var readCommands = function (client, folderPath) { return __awaiter(void 0, void 0, void 0, function () {
51
- var table, files, prefixCommandCount, _loop_1, _i, files_1, file, tableString, error_1;
52
- return __generator(this, function (_a) {
53
- switch (_a.label) {
54
- case 0:
55
- table = new AsciiTable('\x1b[33m Prefix Commands \x1b[0m');
56
- table.setHeading('Commands', 'Status');
57
- _a.label = 1;
58
- case 1:
59
- _a.trys.push([1, 8, , 9]);
60
- return [4 /*yield*/, fs_1.promises.access(folderPath)];
61
- case 2:
62
- _a.sent();
63
- return [4 /*yield*/, fs_1.promises.readdir(folderPath, { withFileTypes: true })];
64
- case 3:
65
- files = _a.sent();
66
- prefixCommandCount = 0;
67
- _loop_1 = function (file) {
68
- var filePath, _b, command_1, error_2;
69
- return __generator(this, function (_c) {
70
- switch (_c.label) {
71
- case 0:
72
- filePath = path_1.join(folderPath, file.name);
73
- if (!file.isDirectory()) return [3 /*break*/, 2];
74
- _b = prefixCommandCount;
75
- return [4 /*yield*/, readCommands(client, filePath)];
76
- case 1:
77
- prefixCommandCount = _b + _c.sent();
78
- return [3 /*break*/, 6];
79
- case 2:
80
- if (!file.isFile()) return [3 /*break*/, 6];
81
- _c.label = 3;
82
- case 3:
83
- _c.trys.push([3, 5, , 6]);
84
- return [4 /*yield*/, Promise.resolve("".concat(filePath)).then(function (s) { return require(s); })];
85
- case 4:
86
- command_1 = _c.sent();
87
- if (command_1 && (command_1.execute || command_1.run)) {
88
- commands.set(command_1.name, command_1);
89
- commandNames.add(command_1.name);
90
- if (command_1.aliases && Array.isArray(command_1.aliases)) {
91
- command_1.aliases.forEach(function (alias) {
92
- aliases.set(alias, command_1.name);
93
- commandNames.add(alias);
94
- });
95
- }
96
- command_1.description =
97
- command_1.description || "No description provided.";
98
- command_1.cooldown = command_1.cooldown || 1;
99
- command_1.usage = command_1.usage || "No usage information provided.";
100
- if (command_1.prefix) {
101
- prefixCommandCount++;
102
- }
103
- table.addRow(command_1.name, '🟢 Registered');
104
- }
105
- else {
106
- console.warn("\x1b[31m%s\x1b[0m", "Ignoring invalid command file: ".concat(filePath));
107
- table.addRow(filePath, '🔴 Invalid');
108
- }
109
- return [3 /*break*/, 6];
110
- case 5:
111
- error_2 = _c.sent();
112
- console.error("\x1b[31m%s\x1b[0m", "Error in file: ".concat(filePath));
113
- console.error("\x1b[31m%s\x1b[0m", error_2);
114
- table.addRow(filePath, '🔴 Error');
115
- return [3 /*break*/, 6];
116
- case 6: return [2 /*return*/];
117
- }
118
- });
119
- };
120
- _i = 0, files_1 = files;
121
- _a.label = 4;
122
- case 4:
123
- if (!(_i < files_1.length)) return [3 /*break*/, 7];
124
- file = files_1[_i];
125
- return [5 /*yield**/, _loop_1(file)];
126
- case 5:
127
- _a.sent();
128
- _a.label = 6;
129
- case 6:
130
- _i++;
131
- return [3 /*break*/, 4];
132
- case 7:
133
- tableString = table.toString();
134
- console.log(tableString.trim());
135
-
136
- return [2 /*return*/, prefixCommandCount];
137
- case 8:
138
- error_1 = _a.sent();
139
- console.error("\x1b[31m%s\x1b[0m", "Error reading directory: ".concat(folderPath));
140
- console.error("\x1b[31m%s\x1b[0m", error_1);
141
- return [2 /*return*/, 0];
142
- case 9: return [2 /*return*/];
143
- }
144
- });
145
- });
146
- };
147
-
148
- exports.readCommands = readCommands;
@@ -1,163 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.prefixRespond = void 0;
40
- var discord_js_1 = require("discord.js");
41
- var prefixRegister_1 = require("./prefixRegister");
42
- var cooldowns = new discord_js_1.Collection();
43
- /**
44
- * Handles the 'messageCreate' event
45
- * @param {Message} message - The received message
46
- * @param {string} commandPrefix - The command prefix for the bot
47
- */
48
- function handleMessageCreate(message, commandPrefix, logs) {
49
- var _a, _b, _c, _d, _e, _f, _g;
50
- return __awaiter(this, void 0, void 0, function () {
51
- var args, commandName, command, now, timestamps_1, cooldownAmount, expirationTime, expirationTime_1, timeLeft, channel, userName, userid, serverName, serverId, messageLink, embedLog;
52
- return __generator(this, function (_h) {
53
- switch (_h.label) {
54
- case 0:
55
- if (!message.content.startsWith(commandPrefix) || message.author.bot)
56
- return [2 /*return*/];
57
- args = message.content
58
- .slice(commandPrefix.length)
59
- .trim()
60
- .split(/ +/);
61
- commandName = (_a = args.shift()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
62
- if (!(commandName && prefixRegister_1.commandNames.has(commandName))) return [3 /*break*/, 10];
63
- command = prefixRegister_1.commands.get(commandName) || prefixRegister_1.commands.get(prefixRegister_1.aliases.get(commandName));
64
- if (!cooldowns.has(command.name)) {
65
- cooldowns.set(command.name, new discord_js_1.Collection());
66
- }
67
- now = Date.now();
68
- timestamps_1 = cooldowns.get(command.name);
69
- cooldownAmount = (command.cooldown || 3) * 1000;
70
- if (!(timestamps_1 && timestamps_1.has(message.author.id))) return [3 /*break*/, 2];
71
- expirationTime = timestamps_1.get(message.author.id)
72
- ? timestamps_1.get(message.author.id) + cooldownAmount
73
- : undefined;
74
- if (!(timestamps_1 && timestamps_1.has(message.author.id))) return [3 /*break*/, 2];
75
- expirationTime_1 = timestamps_1.get(message.author.id)
76
- ? timestamps_1.get(message.author.id) + cooldownAmount
77
- : undefined;
78
- if (!(expirationTime_1 && now < expirationTime_1)) return [3 /*break*/, 2];
79
- timeLeft = (expirationTime_1 - now) / 1000;
80
- return [4 /*yield*/, message.reply("Please wait ".concat(timeLeft.toFixed(1), " more second(s) before reusing the `").concat(command.name, "` command."))];
81
- case 1:
82
- _h.sent();
83
- return [2 /*return*/]; // Add this line to exit the function
84
- case 2:
85
- if (timestamps_1) {
86
- timestamps_1.set(message.author.id, now);
87
- setTimeout(function () { return timestamps_1.delete(message.author.id); }, cooldownAmount);
88
- }
89
- channel = (_b = message.guild) === null || _b === void 0 ? void 0 : _b.channels.cache.get(logs);
90
- userName = message.author.username;
91
- userid = message.author.id;
92
- serverName = ((_c = message.guild) === null || _c === void 0 ? void 0 : _c.name) || null;
93
- serverId = ((_d = message.guild) === null || _d === void 0 ? void 0 : _d.id) || null;
94
- messageLink = "https://discord.com/channels/".concat((_e = message.guild) === null || _e === void 0 ? void 0 : _e.id, "/").concat((_f = message.channel) === null || _f === void 0 ? void 0 : _f.id, "/").concat(message.id);
95
- embedLog = new discord_js_1.EmbedBuilder()
96
- .setColor("Blue")
97
- .setThumbnail((_g = message.client.user) === null || _g === void 0 ? void 0 : _g.displayAvatarURL({ dynamic: true }))
98
- .setTitle("Use Prefix Command")
99
- .addFields({ name: "\uD83D\uDD27 Cmd:", value: "- ".concat(command.name), inline: true }, {
100
- name: "\uD83E\uDEAA User:",
101
- value: "- ".concat(userName, " (<@").concat(userid, ">)"),
102
- inline: true,
103
- }, { name: "\u200B", value: "\u200B", inline: true }, {
104
- name: "\uD83D\uDEF0\uFE0F Server:",
105
- value: "- ".concat(serverName, ".\n- `[").concat(serverId, "]`."),
106
- inline: true,
107
- }, {
108
- name: "\uD83D\uDCE8 Message:",
109
- value: "- [Link](".concat(messageLink, ")"),
110
- inline: true,
111
- }, { name: "\u200B", value: "\u200B", inline: true }, {
112
- name: "\u23F1\uFE0F Date:",
113
- value: "- <t:".concat(Math.floor(Date.now() / 1000), ":R>"),
114
- inline: true,
115
- });
116
- if (!command.run) return [3 /*break*/, 6];
117
- return [4 /*yield*/, command.run(message.client, message, args)];
118
- case 3:
119
- _h.sent();
120
- if (!(logs && channel)) return [3 /*break*/, 5];
121
- return [4 /*yield*/, channel.send({
122
- embeds: [embedLog],
123
- })];
124
- case 4:
125
- _h.sent();
126
- _h.label = 5;
127
- case 5: return [3 /*break*/, 9];
128
- case 6:
129
- if (!command.execute) return [3 /*break*/, 9];
130
- return [4 /*yield*/, command.execute(message.client, message, args)];
131
- case 7:
132
- _h.sent();
133
- if (!(logs && channel)) return [3 /*break*/, 9];
134
- return [4 /*yield*/, channel.send({
135
- embeds: [embedLog],
136
- })];
137
- case 8:
138
- _h.sent();
139
- _h.label = 9;
140
- case 9: return [3 /*break*/, 11];
141
- case 10:
142
- console.log("Command not found!");
143
- _h.label = 11;
144
- case 11: return [2 /*return*/];
145
- }
146
- });
147
- });
148
- }
149
- /**
150
- * Setup the 'messageCreate' event
151
- * @param {Client} client - The Discord client
152
- * @param {string} commandPrefix - The command prefix for the bot
153
- */
154
- function prefixRespond(client, commandPrefix, logs) {
155
- if (!commandPrefix) {
156
- throw new Error("No command prefix provided. Please provide a command prefix.");
157
- }
158
- client.on("messageCreate", function (message) {
159
- return handleMessageCreate(message, commandPrefix, logs);
160
- });
161
- }
162
-
163
- exports.prefixRespond = prefixRespond;