apexify.js 2.4.4-beta.1 → 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 -82
  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 -62
  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,183 +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.registerSlashCommands = void 0;
40
- var rest_1 = require("@discordjs/rest");
41
- var v10_1 = require("discord-api-types/v10");
42
- var fs = require("fs/promises");
43
- var discord_js_1 = require("discord.js");
44
- var path_1 = require("path");
45
- var AsciiTable = require("ascii-table");
46
- /**
47
- * Register slash commands for the bot
48
- * @param {Client} client - The Discord client
49
- * @param {string} token - Bot token
50
- * @param {string} baseDirectory - Base directory for slash commands
51
- * @param {string} baseDir - Base directory path
52
- */
53
- function registerSlashCommands(client, token, baseDirectory, baseDir, gId, gl) {
54
- var _a, _b;
55
- return __awaiter(this, void 0, void 0, function () {
56
- var table, slashCommands, rest, resolvedPath_1, dirents, slashCommandArray, error_1, guild, slashCommandArray, error_2, error_3, tableString;
57
- var _this = this;
58
- return __generator(this, function (_c) {
59
- switch (_c.label) {
60
- case 0:
61
- table = new AsciiTable('\x1b[33m Slash Commands \x1b[0m');
62
- table.setHeading('Commands', 'Status');
63
- slashCommands = new discord_js_1.Collection();
64
- client.slashCommands = new discord_js_1.Collection();
65
- rest = new rest_1.REST({ version: '10' }).setToken(token);
66
- _c.label = 1;
67
- case 1:
68
- _c.trys.push([1, 15, , 16]);
69
- resolvedPath_1 = path_1.join(baseDir, baseDirectory);
70
- return [4 /*yield*/, fs.readdir(resolvedPath_1, { withFileTypes: true })];
71
- case 2:
72
- dirents = _c.sent();
73
- return [4 /*yield*/, Promise.all(dirents.map(function (dirent) { return __awaiter(_this, void 0, void 0, function () {
74
- var folderPath_1, files, command;
75
- var _this = this;
76
- return __generator(this, function (_a) {
77
- switch (_a.label) {
78
- case 0:
79
- if (!dirent.isDirectory()) return [3 /*break*/, 3];
80
- folderPath_1 = path_1.join(resolvedPath_1, dirent.name);
81
- return [4 /*yield*/, fs.readdir(folderPath_1)];
82
- case 1:
83
- files = _a.sent();
84
- return [4 /*yield*/, Promise.all(files.map(function (file) { return __awaiter(_this, void 0, void 0, function () {
85
- var command;
86
- return __generator(this, function (_a) {
87
- try {
88
- command = require(path_1.join(folderPath_1, file));
89
- if (command.data) {
90
- if (command.cooldown && !isNaN(command.cooldown)) {
91
- command.data.cooldown = command.cooldown;
92
- }
93
- slashCommands.set(command.data.name, command);
94
- client.slashCommands.set(command.data.name, command);
95
- table.addRow(command.data.name, '🟢 Registered\x1b');
96
- }
97
- }
98
- catch (error) {
99
- console.error('\x1b[31m%s\x1b[0m', "Error in file: ".concat(path_1.join(folderPath_1, file)));
100
- console.error('\x1b[31m%s\x1b[0m', error);
101
- table.addRow(path_1.join(folderPath_1, file), '🔴 Error');
102
- }
103
- return [2 /*return*/];
104
- });
105
- }); }))];
106
- case 2:
107
- _a.sent();
108
- return [3 /*break*/, 4];
109
- case 3:
110
- try {
111
- command = require(path_1.join(resolvedPath_1, dirent.name));
112
- if (command.data) {
113
- if (command.cooldown && !isNaN(command.cooldown)) {
114
- command.data.cooldown = command.cooldown || 0;
115
- }
116
- slashCommands.set(command.data.name, command);
117
- client.slashCommands.set(command.data.name, command);
118
- table.addRow(command.data.name, '🟢 Registered');
119
- }
120
- }
121
- catch (error) {
122
- console.error('\x1b[31m%s\x1b[0m', "Error in file: ".concat(path_1.join(resolvedPath_1, dirent.name)));
123
- console.error('\x1b[31m%s\x1b[0m', error);
124
- table.addRow(path_1.join(resolvedPath_1, dirent.name), '🔴 Error');
125
- }
126
- _a.label = 4;
127
- case 4: return [2 /*return*/];
128
- }
129
- });
130
- }); }))];
131
- case 3:
132
- _c.sent();
133
- if (!(!gId && gl === true)) return [3 /*break*/, 8];
134
- slashCommandArray = Array.from(slashCommands.values()).map(function (command) { return command.data.toJSON(); });
135
- _c.label = 4;
136
- case 4:
137
- _c.trys.push([4, 6, , 7]);
138
- return [4 /*yield*/, rest.put(v10_1.Routes.applicationCommands(((_a = client.user) === null || _a === void 0 ? void 0 : _a.id) || ''), { body: slashCommandArray, headers: { Authorization: "Bot ".concat(token) } })];
139
- case 5:
140
- _c.sent();
141
- console.log('\x1b[36m%s\x1b[0m', "Registered ".concat(slashCommandArray.length, " global slash commands."));
142
- return [3 /*break*/, 7];
143
- case 6:
144
- error_1 = _c.sent();
145
- console.error('\x1b[31m%s\x1b[0m', 'Error setting global slash commands:', error_1.message);
146
- return [3 /*break*/, 7];
147
- case 7: return [3 /*break*/, 14];
148
- case 8:
149
- if (!(gId && gl === false)) return [3 /*break*/, 14];
150
- guild = client.guilds.cache.get(gId);
151
- if (!guild) return [3 /*break*/, 13];
152
- slashCommandArray = Array.from(slashCommands.values()).map(function (command) { return command.data.toJSON(); });
153
- _c.label = 9;
154
- case 9:
155
- _c.trys.push([9, 11, , 12]);
156
- return [4 /*yield*/, rest.put(v10_1.Routes.applicationGuildCommands(((_b = client.user) === null || _b === void 0 ? void 0 : _b.id) || '', guild.id), { body: slashCommandArray, headers: { Authorization: "Bot ".concat(token) } })];
157
- case 10:
158
- _c.sent();
159
- console.log('\x1b[36m%s\x1b[0m', "Registered ".concat(slashCommandArray.length, " guild-specific slash commands for guild ").concat(guild.name, "."));
160
- return [3 /*break*/, 12];
161
- case 11:
162
- error_2 = _c.sent();
163
- console.error('\x1b[31m%s\x1b[0m', "Error setting guild-specific slash commands for guild ".concat(guild.name, ":"), error_2.message);
164
- return [3 /*break*/, 12];
165
- case 12: return [3 /*break*/, 14];
166
- case 13:
167
- console.error('\x1b[31m%s\x1b[0m', "Guild with ID ".concat(gId, " not found."));
168
- _c.label = 14;
169
- case 14: return [3 /*break*/, 16];
170
- case 15:
171
- error_3 = _c.sent();
172
- console.error('\x1b[31m%s\x1b[0m', 'Error registering slash commands:', error_3.message);
173
- return [3 /*break*/, 16];
174
- case 16:
175
- tableString = table.toString();
176
- console.log(tableString.trim());
177
- return [2 /*return*/, slashCommands];
178
- }
179
- });
180
- });
181
- }
182
-
183
- exports.registerSlashCommands = registerSlashCommands;
@@ -1,108 +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.slashRespond = void 0;
40
- var discord_js_1 = require("discord.js");
41
- function slashRespond(client, slashCommands) {
42
- var _this = this;
43
- // Check if there is at least one registered slash command
44
- if (!slashCommands || slashCommands.size === 0) {
45
- console.log('\x1b[33m%s\x1b[0m', 'No registered slash commands. The slashRespond function will not work.');
46
- return;
47
- }
48
- var interactionCooldowns = new discord_js_1.Collection();
49
- client.on('interactionCreate', function (interaction) { return __awaiter(_this, void 0, void 0, function () {
50
- var command, userCooldowns, cooldownExpiration, remainingCooldown, startExecutionTime, executionTime, error_1;
51
- return __generator(this, function (_a) {
52
- switch (_a.label) {
53
- case 0:
54
- if (!interaction.isCommand() || !interaction.guild || !interaction.isChatInputCommand() || interaction.user.bot)
55
- return [2 /*return*/];
56
- command = slashCommands.get(interaction.commandName);
57
- if (!command)
58
- return [2 /*return*/];
59
- if (!(command.cooldown && !isNaN(command.cooldown))) return [3 /*break*/, 3];
60
- userCooldowns = interactionCooldowns.get(interaction.user.id) || new discord_js_1.Collection();
61
- cooldownExpiration = userCooldowns.get(command.data.name);
62
- if (!(cooldownExpiration && cooldownExpiration > Date.now())) return [3 /*break*/, 2];
63
- remainingCooldown = (cooldownExpiration - Date.now()) / 1000;
64
- return [4 /*yield*/, interaction.reply("\u001B[33mCommand is on cooldown. Please wait ".concat(remainingCooldown.toFixed(1), " seconds.\u001B[0m"))];
65
- case 1:
66
- _a.sent();
67
- return [2 /*return*/];
68
- case 2:
69
- userCooldowns.set(command.data.name, Date.now() + command.cooldown * 1000);
70
- interactionCooldowns.set(interaction.user.id, userCooldowns);
71
- _a.label = 3;
72
- case 3:
73
- _a.trys.push([3, 9, , 11]);
74
- startExecutionTime = Date.now();
75
- if (!command.run) return [3 /*break*/, 5];
76
- return [4 /*yield*/, command.run(client, interaction)];
77
- case 4:
78
- _a.sent();
79
- return [3 /*break*/, 8];
80
- case 5:
81
- if (!command.execute) return [3 /*break*/, 7];
82
- return [4 /*yield*/, command.execute(client, interaction)];
83
- case 6:
84
- _a.sent();
85
- return [3 /*break*/, 8];
86
- case 7:
87
- console.log('\x1b[33m%s\x1b[0m', "Command \"".concat(command.data.name, "\" has neither run nor execute method."));
88
- _a.label = 8;
89
- case 8:
90
- executionTime = Date.now() - startExecutionTime;
91
- if (executionTime > 3000) {
92
- console.log('\x1b[33m%s\x1b[0m', "Command \"".concat(command.data.name, "\" took ").concat(executionTime, "ms to execute."));
93
- }
94
- return [3 /*break*/, 11];
95
- case 9:
96
- error_1 = _a.sent();
97
- console.error('\x1b[31m%s\x1b[0m', "Error executing command \"".concat(command.data.name, "\":"), error_1);
98
- return [4 /*yield*/, interaction.channel.send('An error occurred while executing the command.')];
99
- case 10:
100
- _a.sent();
101
- return [3 /*break*/, 11];
102
- case 11: return [2 /*return*/];
103
- }
104
- });
105
- }); });
106
- }
107
-
108
- exports.slashRespond = slashRespond;