djs-builder 0.5.42 → 0.6.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 (156) hide show
  1. package/README.md +140 -303
  2. package/function/function.js +236 -0
  3. package/function/log.js +736 -0
  4. package/handler/helper.js +277 -0
  5. package/handler/starter.js +335 -0
  6. package/package.json +10 -42
  7. package/.tsbuildinfo +0 -1
  8. package/dist/discord/builder/components/Buttons.d.ts +0 -22
  9. package/dist/discord/builder/components/Buttons.d.ts.map +0 -1
  10. package/dist/discord/builder/components/Buttons.js +0 -91
  11. package/dist/discord/builder/components/Buttons.js.map +0 -1
  12. package/dist/discord/builder/components/Menus.d.ts +0 -31
  13. package/dist/discord/builder/components/Menus.d.ts.map +0 -1
  14. package/dist/discord/builder/components/Menus.js +0 -82
  15. package/dist/discord/builder/components/Menus.js.map +0 -1
  16. package/dist/discord/builder/permissions/perms.d.ts +0 -6
  17. package/dist/discord/builder/permissions/perms.d.ts.map +0 -1
  18. package/dist/discord/builder/permissions/perms.js +0 -66
  19. package/dist/discord/builder/permissions/perms.js.map +0 -1
  20. package/dist/discord/builder/system/Pagination.d.ts +0 -68
  21. package/dist/discord/builder/system/Pagination.d.ts.map +0 -1
  22. package/dist/discord/builder/system/Pagination.js +0 -256
  23. package/dist/discord/builder/system/Pagination.js.map +0 -1
  24. package/dist/discord/builder/system/collectors.d.ts +0 -27
  25. package/dist/discord/builder/system/collectors.d.ts.map +0 -1
  26. package/dist/discord/builder/system/collectors.js +0 -137
  27. package/dist/discord/builder/system/collectors.js.map +0 -1
  28. package/dist/discord/builder/utils.d.ts +0 -5
  29. package/dist/discord/builder/utils.d.ts.map +0 -1
  30. package/dist/discord/builder/utils.js +0 -10
  31. package/dist/discord/builder/utils.js.map +0 -1
  32. package/dist/discord/events-handler/eventLoader.d.ts +0 -13
  33. package/dist/discord/events-handler/eventLoader.d.ts.map +0 -1
  34. package/dist/discord/events-handler/eventLoader.js +0 -169
  35. package/dist/discord/events-handler/eventLoader.js.map +0 -1
  36. package/dist/discord/events-handler/events.d.ts +0 -8
  37. package/dist/discord/events-handler/events.d.ts.map +0 -1
  38. package/dist/discord/events-handler/events.js +0 -186
  39. package/dist/discord/events-handler/events.js.map +0 -1
  40. package/dist/discord/events-handler/login.d.ts +0 -9
  41. package/dist/discord/events-handler/login.d.ts.map +0 -1
  42. package/dist/discord/events-handler/login.js +0 -273
  43. package/dist/discord/events-handler/login.js.map +0 -1
  44. package/dist/discord/events-handler/prefix-register.d.ts +0 -23
  45. package/dist/discord/events-handler/prefix-register.d.ts.map +0 -1
  46. package/dist/discord/events-handler/prefix-register.js +0 -109
  47. package/dist/discord/events-handler/prefix-register.js.map +0 -1
  48. package/dist/discord/events-handler/prefix-responder.d.ts +0 -5
  49. package/dist/discord/events-handler/prefix-responder.d.ts.map +0 -1
  50. package/dist/discord/events-handler/prefix-responder.js +0 -155
  51. package/dist/discord/events-handler/prefix-responder.js.map +0 -1
  52. package/dist/discord/events-handler/prefixLoader.d.ts +0 -7
  53. package/dist/discord/events-handler/prefixLoader.d.ts.map +0 -1
  54. package/dist/discord/events-handler/prefixLoader.js +0 -74
  55. package/dist/discord/events-handler/prefixLoader.js.map +0 -1
  56. package/dist/discord/events-handler/slash-register.d.ts +0 -4
  57. package/dist/discord/events-handler/slash-register.d.ts.map +0 -1
  58. package/dist/discord/events-handler/slash-register.js +0 -85
  59. package/dist/discord/events-handler/slash-register.js.map +0 -1
  60. package/dist/discord/events-handler/slash-responder.d.ts +0 -3
  61. package/dist/discord/events-handler/slash-responder.d.ts.map +0 -1
  62. package/dist/discord/events-handler/slash-responder.js +0 -112
  63. package/dist/discord/events-handler/slash-responder.js.map +0 -1
  64. package/dist/discord/events-handler/slashLoader.d.ts +0 -7
  65. package/dist/discord/events-handler/slashLoader.d.ts.map +0 -1
  66. package/dist/discord/events-handler/slashLoader.js +0 -94
  67. package/dist/discord/events-handler/slashLoader.js.map +0 -1
  68. package/dist/discord/events-handler/starter.d.ts +0 -6
  69. package/dist/discord/events-handler/starter.d.ts.map +0 -1
  70. package/dist/discord/events-handler/starter.js +0 -85
  71. package/dist/discord/events-handler/starter.js.map +0 -1
  72. package/dist/discord/functions/anticrash.d.ts +0 -3
  73. package/dist/discord/functions/anticrash.d.ts.map +0 -1
  74. package/dist/discord/functions/anticrash.js +0 -55
  75. package/dist/discord/functions/anticrash.js.map +0 -1
  76. package/dist/discord/functions/devLogs.d.ts +0 -2
  77. package/dist/discord/functions/devLogs.d.ts.map +0 -1
  78. package/dist/discord/functions/devLogs.js +0 -137
  79. package/dist/discord/functions/devLogs.js.map +0 -1
  80. package/dist/discord/functions/logger.d.ts +0 -5
  81. package/dist/discord/functions/logger.d.ts.map +0 -1
  82. package/dist/discord/functions/logger.js +0 -57
  83. package/dist/discord/functions/logger.js.map +0 -1
  84. package/dist/discord/functions/mongoDb.d.ts +0 -4
  85. package/dist/discord/functions/mongoDb.d.ts.map +0 -1
  86. package/dist/discord/functions/mongoDb.js +0 -39
  87. package/dist/discord/functions/mongoDb.js.map +0 -1
  88. package/dist/discord/functions/similarity.d.ts +0 -3
  89. package/dist/discord/functions/similarity.d.ts.map +0 -1
  90. package/dist/discord/functions/similarity.js +0 -56
  91. package/dist/discord/functions/similarity.js.map +0 -1
  92. package/dist/discord/functions/terminal.d.ts +0 -2
  93. package/dist/discord/functions/terminal.d.ts.map +0 -1
  94. package/dist/discord/functions/terminal.js +0 -127
  95. package/dist/discord/functions/terminal.js.map +0 -1
  96. package/dist/discord/functions/utils.d.ts +0 -5
  97. package/dist/discord/functions/utils.d.ts.map +0 -1
  98. package/dist/discord/functions/utils.js +0 -11
  99. package/dist/discord/functions/utils.js.map +0 -1
  100. package/dist/discord/functions/versedb.d.ts +0 -3
  101. package/dist/discord/functions/versedb.d.ts.map +0 -1
  102. package/dist/discord/functions/versedb.js +0 -21
  103. package/dist/discord/functions/versedb.js.map +0 -1
  104. package/dist/discord/games/X-O.d.ts +0 -20
  105. package/dist/discord/games/X-O.d.ts.map +0 -1
  106. package/dist/discord/games/X-O.js +0 -166
  107. package/dist/discord/games/X-O.js.map +0 -1
  108. package/dist/discord/games/rps.d.ts +0 -21
  109. package/dist/discord/games/rps.d.ts.map +0 -1
  110. package/dist/discord/games/rps.js +0 -99
  111. package/dist/discord/games/rps.js.map +0 -1
  112. package/dist/discord/types/starter.d.ts +0 -144
  113. package/dist/discord/types/starter.d.ts.map +0 -1
  114. package/dist/discord/types/starter.js +0 -3
  115. package/dist/discord/types/starter.js.map +0 -1
  116. package/dist/discord/types/utils.d.ts +0 -3
  117. package/dist/discord/types/utils.d.ts.map +0 -1
  118. package/dist/discord/types/utils.js +0 -3
  119. package/dist/discord/types/utils.js.map +0 -1
  120. package/dist/discord/utils.d.ts +0 -15
  121. package/dist/discord/utils.d.ts.map +0 -1
  122. package/dist/discord/utils.js +0 -41
  123. package/dist/discord/utils.js.map +0 -1
  124. package/dist/index.d.ts +0 -4
  125. package/dist/index.d.ts.map +0 -1
  126. package/dist/index.js +0 -71
  127. package/dist/index.js.map +0 -1
  128. package/lib/discord/builder/components/Buttons.ts +0 -123
  129. package/lib/discord/builder/components/Menus.ts +0 -106
  130. package/lib/discord/builder/permissions/perms.ts +0 -66
  131. package/lib/discord/builder/system/Pagination.ts +0 -374
  132. package/lib/discord/builder/system/collectors.ts +0 -197
  133. package/lib/discord/builder/utils.ts +0 -9
  134. package/lib/discord/events-handler/eventLoader.ts +0 -166
  135. package/lib/discord/events-handler/events.ts +0 -160
  136. package/lib/discord/events-handler/login.ts +0 -265
  137. package/lib/discord/events-handler/prefix-register.ts +0 -117
  138. package/lib/discord/events-handler/prefix-responder.ts +0 -176
  139. package/lib/discord/events-handler/prefixLoader.ts +0 -83
  140. package/lib/discord/events-handler/slash-register.ts +0 -81
  141. package/lib/discord/events-handler/slash-responder.ts +0 -136
  142. package/lib/discord/events-handler/slashLoader.ts +0 -104
  143. package/lib/discord/events-handler/starter.ts +0 -85
  144. package/lib/discord/functions/anticrash.ts +0 -60
  145. package/lib/discord/functions/devLogs.ts +0 -128
  146. package/lib/discord/functions/logger.ts +0 -58
  147. package/lib/discord/functions/mongoDb.ts +0 -38
  148. package/lib/discord/functions/similarity.ts +0 -70
  149. package/lib/discord/functions/terminal.ts +0 -162
  150. package/lib/discord/functions/utils.ts +0 -4
  151. package/lib/discord/functions/versedb.ts +0 -17
  152. package/lib/discord/types/starter.ts +0 -158
  153. package/lib/discord/types/utils.ts +0 -2
  154. package/lib/discord/utils.ts +0 -17
  155. package/lib/index.ts +0 -37
  156. package/tsconfig.json +0 -21
@@ -0,0 +1,277 @@
1
+ const { EmbedBuilder, WebhookClient } = require("discord.js");
2
+ const Table = require("cli-table3");
3
+ const chalk = require("chalk");
4
+ const path = require("path");
5
+ const fs = require("fs");
6
+ const axios = require("axios");
7
+
8
+ async function cooldowns(client, name, time, user) {
9
+ const cooldownKey = `${name}_${user.id}`;
10
+ const now = Date.now();
11
+
12
+ if (!client.cooldowns) client.cooldowns = new Map();
13
+
14
+ if (client.cooldowns.has(cooldownKey)) {
15
+ const expirationTime = client.cooldowns.get(cooldownKey);
16
+ if (now < expirationTime) {
17
+ const remaining = ((expirationTime - now) / 1000).toFixed(1);
18
+ return {
19
+ text: `⏳ انتظر ${remaining} ثانية قبل استخدام هذا الأمر مرة أخرى.`,
20
+ type: true,
21
+ };
22
+ }
23
+ }
24
+
25
+ client.cooldowns.set(cooldownKey, now + time * 1000);
26
+
27
+ setTimeout(() => client.cooldowns.delete(cooldownKey), time * 1000);
28
+
29
+ return {
30
+ type: false,
31
+ };
32
+ }
33
+
34
+ async function readFile(dir) {
35
+ if (!path.isAbsolute(dir)) {
36
+ dir = path.join(process.cwd(), dir);
37
+ }
38
+
39
+ let final_file_data = [];
40
+
41
+ const files = fs.readdirSync(dir, { withFileTypes: true });
42
+
43
+ for (const file of files) {
44
+ const file_path = path.join(dir, file.name);
45
+
46
+ if (file.isDirectory()) {
47
+ const nested = await readFile(file_path);
48
+ final_file_data = final_file_data.concat(nested);
49
+ } else {
50
+ final_file_data.push({
51
+ name: file.name,
52
+ path: file_path,
53
+ });
54
+ }
55
+ }
56
+
57
+ return final_file_data;
58
+ }
59
+
60
+ async function terminalInfo(client, options, data) {
61
+ const firstTable = new Table({
62
+ head: [chalk.bold.blue("🧩 Info"), chalk.bold.green("📌 Value")],
63
+ colWidths: [30, 50],
64
+ });
65
+
66
+ const secondTable = new Table({
67
+ head: [chalk.bold.magenta("👤 Setting"), chalk.bold.cyan("🔧 Detail")],
68
+ colWidths: [30, 50],
69
+ });
70
+
71
+ const rowColors = [
72
+ chalk.cyanBright,
73
+ chalk.greenBright,
74
+ chalk.magentaBright,
75
+ chalk.blueBright,
76
+ chalk.yellowBright,
77
+ chalk.redBright,
78
+ chalk.whiteBright,
79
+ chalk.gray,
80
+ chalk.white,
81
+ chalk.green,
82
+ ];
83
+
84
+ firstTable.push(
85
+ [rowColors[0]("Name"), rowColors[0](client.user.username)],
86
+ [rowColors[1]("Users"), rowColors[1](client.users.cache.size)],
87
+ [rowColors[2]("Guilds"), rowColors[2](client.guilds.cache.size)],
88
+ [rowColors[3]("Channels"), rowColors[3](client.channels.cache.size)],
89
+ [rowColors[4]("Prefix Commands"), rowColors[4](data.prefix)],
90
+ [rowColors[5]("Slash Commands"), rowColors[5](data.slash)],
91
+ [rowColors[6]("Total Commands"), rowColors[6](data.slash + data.prefix)],
92
+ [rowColors[7]("Events"), rowColors[7](data.event)],
93
+ [rowColors[8]("Started At"), rowColors[8](new Date().toLocaleString())]
94
+ );
95
+
96
+ secondTable.push(
97
+ [rowColors[0]("Bot Owner"), rowColors[0](client.owner.id)],
98
+ [
99
+ rowColors[1]("Bot Invite"),
100
+ rowColors[1](
101
+ `https://discord.com/oauth2/authorize?client_id=${client.user.id}&permissions=8&integration_type=0&scope=bot`
102
+ ),
103
+ ],
104
+ [
105
+ rowColors[2]("Bot Status"),
106
+ rowColors[2](options.Status.status || "Not Defined"),
107
+ ],
108
+ [
109
+ rowColors[5]("Bot Activity"),
110
+ rowColors[5](
111
+ options.Status.activities
112
+ ? Array.isArray(options.Status.activities)
113
+ ? options.Status.activities[0]
114
+ : options.Status.activities
115
+ : "Not Defined"
116
+ ),
117
+ ]
118
+ );
119
+
120
+ if (options.database?.url) {
121
+ const result = await data_conecter(options.database.url);
122
+ if (result) {
123
+ secondTable.push([chalk.cyan("Database"), rowColors[9]("Connected")]);
124
+ }
125
+ }
126
+
127
+ console.log(chalk.bold.green("\n✅ Bot Information:\n"));
128
+ console.log(firstTable.toString());
129
+
130
+ console.log(chalk.bold.blue("\n⚙️ Developer Settings:\n"));
131
+ console.log(secondTable.toString());
132
+ }
133
+
134
+ async function data_conecter(url) {
135
+ try {
136
+ const mongoose = require("mongoose");
137
+ await mongoose.connect(url);
138
+ return true;
139
+ } catch (error) {
140
+ console.error("❌ فشل الاتصال بقاعدة البيانات:", error);
141
+ return false;
142
+ }
143
+ }
144
+
145
+ async function set_anticrash(data) {
146
+ const webhookURL = data.url,
147
+ id = data.mention_id;
148
+ if (!webhookURL)
149
+ return console.log(chalk.red("❌ Webhook URL is not defined."));
150
+
151
+ const crash = new WebhookClient({ url: webhookURL });
152
+
153
+ const types = {
154
+ error: {
155
+ title: "❌ Error",
156
+ color: "Red",
157
+ },
158
+ warn: {
159
+ title: "⚠️ Warning",
160
+ color: "Yellow",
161
+ },
162
+ info: {
163
+ title: "ℹ️ Info",
164
+ color: "Blue",
165
+ },
166
+ };
167
+
168
+ const send = async (error, type = "info") => {
169
+ const embed = new EmbedBuilder()
170
+ .setTitle(types[type].title)
171
+ .setDescription(`\`\`\`\n${error}\n\`\`\``)
172
+ .setColor(types[type].color)
173
+ .setTimestamp();
174
+
175
+ try {
176
+ await crash.send({
177
+ content: id ? `<@${id}>` : "",
178
+ embeds: [embed],
179
+ });
180
+ console.log(error);
181
+ } catch (e) {
182
+ console.error(chalk.red("❌ Error sending message to webhook:"), e);
183
+ console.log(error);
184
+ }
185
+ };
186
+
187
+ process.on("unhandledRejection", (error) => send(error, "error"));
188
+ process.on("uncaughtException", (error) => send(error, "error"));
189
+ process.on("uncaughtExceptionMonitor", (error) => send(error, "error"));
190
+ process.on("unhandledRejectionMonitor", (error) => send(error, "error"));
191
+ process.on("warning", (error) => send(error, "warn"));
192
+ }
193
+
194
+ async function cmd_log(client, data, commandName, channelId) {
195
+ const isSlash = !!data.user;
196
+ const user = isSlash ? data.user : data.author;
197
+ const channel = data.guild ? data.channel : "DM";
198
+ const messageUrl = data.message?.url || "—";
199
+
200
+ const logChannel = client.channels.cache.get(channelId);
201
+ if (!logChannel) return;
202
+
203
+ const embed = new EmbedBuilder()
204
+ .setTitle(isSlash ? "📘 Slash Command Log" : "📗 Prefix Command Log")
205
+ .setColor(isSlash ? "Green" : "Blue")
206
+ .addFields(
207
+ { name: "📝 Command", value: `\`${commandName}\``, inline: true },
208
+ {
209
+ name: "👤 User",
210
+ value: `${user.tag || user.username} (${user.id})`,
211
+ inline: true,
212
+ },
213
+ { name: "💬 Channel", value: `${channel}`, inline: true },
214
+ { name: "🔗 Message", value: `[Link](${messageUrl})`, inline: true },
215
+ {
216
+ name: "🕒 Date",
217
+ value: `<t:${Math.floor(Date.now() / 1000)}:F>`,
218
+ inline: true,
219
+ }
220
+ )
221
+ .setTimestamp();
222
+
223
+ logChannel.send({ embeds: [embed] }).catch(console.error);
224
+ }
225
+
226
+ //////////////////////////////////* Check update 🔼
227
+
228
+ async function update(client, id, webhookURL) {
229
+ const { version, note: localNote } = require("../package.json");
230
+
231
+ const { data } = await axios.get(
232
+ `https://registry.npmjs.org/testsss-akazaz-lib/latest`
233
+ );
234
+ const new_version = data.version;
235
+ const note = data.discription || "";
236
+
237
+ if (
238
+ client.djs_builder_version &&
239
+ client.djs_builder_version === new_version
240
+ ) {
241
+ return;
242
+ }
243
+
244
+ if (new_version !== version) {
245
+ console.log(
246
+ chalk.yellow(
247
+ `⚠️ New version available: ${new_version} (Your version: ${version})`
248
+ )
249
+ );
250
+
251
+ const crash = new WebhookClient({ url: webhookURL });
252
+
253
+ const embed = new EmbedBuilder()
254
+ .setTitle("🎉 New version available")
255
+ .setDescription(
256
+ `${note}\n\n**Your version:** ${version} ⏰\n**New version:** ${new_version} 🚀\n- Try running \`npm i testsss-akazaz-lib@latest\` to update. ❤`
257
+ )
258
+ .setColor("Yellow")
259
+ .setTimestamp();
260
+
261
+ await crash.send({ content: `<@${id}>`, embeds: [embed] }).catch((e) => {});
262
+ } else if (note && note !== localNote) {
263
+ console.log(chalk.cyan("📝 New note available without version change:"));
264
+ console.log(note);
265
+ }
266
+
267
+ client.djs_builder_version = new_version;
268
+ }
269
+
270
+ module.exports = {
271
+ cooldowns,
272
+ readFile,
273
+ terminalInfo,
274
+ set_anticrash,
275
+ cmd_log,
276
+ update,
277
+ };
@@ -0,0 +1,335 @@
1
+ const {
2
+ readFile,
3
+ cooldowns,
4
+ terminalInfo,
5
+ set_anticrash,
6
+ cmd_log,
7
+ update
8
+ } = require("./helper");
9
+ let termenal = {
10
+ prefix: 0,
11
+ slash: 0,
12
+ event: 0,
13
+ };
14
+
15
+ async function starter(client, options) {
16
+ //////////////////////////////////////////! mine data !////////////////////////////////////////////////////////
17
+ const token = options.bot.token;
18
+ const ownerId = options.bot.ownerId;
19
+ const Status = options.Status || null;
20
+ const prefix = options.prefix || null;
21
+ const slash = options.slash || null;
22
+ const events = options.events || null;
23
+ const anticrash = options.anticrash || null;
24
+ const terminal_info = options.terminal || null;
25
+
26
+ if (terminal_info) {
27
+ console.log("🚀 Bot is starting...");
28
+ }
29
+
30
+ //////////////////////////////////////////* status set !////////////////////////////////////////////////////////
31
+ client.login(token);
32
+ client.once("ready", () => {
33
+ if (Status) {
34
+ const activities = Array.isArray(Status.activities)
35
+ ? Status.activities
36
+ : [Status.activities];
37
+ const type = Status.type ?? 0;
38
+ const time = Status.time ?? 20000;
39
+ const presence = Status.status ?? "online";
40
+
41
+ let index = 0;
42
+
43
+ if (Status.url) {
44
+ setInterval(() => {
45
+ client.user.setPresence({
46
+ activities: [
47
+ { name: activities[index], type },
48
+ { type: 1, url: Status.url },
49
+ ],
50
+ status: presence,
51
+ });
52
+ }, 60 * 1000);
53
+ } else {
54
+ client.user.setPresence({
55
+ activities: [{ name: activities[index], type }],
56
+ status: presence,
57
+ });
58
+ }
59
+
60
+ if (activities.length > 1) {
61
+ setInterval(() => {
62
+ index = (index + 1) % activities.length;
63
+ client.user.setPresence({
64
+ activities: [{ name: activities[index], type }],
65
+ status: presence,
66
+ });
67
+ }, time);
68
+ }
69
+ }
70
+ });
71
+
72
+ //////////////////////////////////////////? Prefix Loader ////////////////////////////////////////////////////////
73
+
74
+ if (prefix) {
75
+ const prefix_files = await readFile(prefix.path);
76
+ client.prefixCommands = new Map();
77
+
78
+ for (const file of prefix_files) {
79
+ const command = require(file.path);
80
+
81
+ if (!command.name || typeof command.run !== "function") continue;
82
+
83
+ const commandWithMeta = {
84
+ ...command,
85
+ file_path: file.path,
86
+ };
87
+
88
+ client.prefixCommands.set(command.name, commandWithMeta);
89
+
90
+ if (Array.isArray(command.aliases)) {
91
+ for (const alias of command.aliases) {
92
+ client.prefixCommands.set(alias, commandWithMeta);
93
+ }
94
+ }
95
+
96
+ termenal.prefix++;
97
+ }
98
+ }
99
+
100
+ //////////////////////////////////////////? Slash Loader ////////////////////////////////////////////////////////
101
+
102
+ if (slash) {
103
+ const slash_files = await readFile(slash.path);
104
+ const validSlashCommands = slash_files
105
+ .map((f) => require(f.path))
106
+ .filter((cmd) => cmd.data && typeof cmd.run === "function");
107
+
108
+ client.slashCommands = new Map(
109
+ validSlashCommands.map((cmd) => [cmd.data.name, cmd])
110
+ );
111
+
112
+ termenal.slash = validSlashCommands.length;
113
+ }
114
+
115
+ //////////////////////////////////////////? Event Loader ////////////////////////////////////////////////////////
116
+
117
+ if (events) {
118
+ const event_files = await readFile(events.path);
119
+ for (const file of event_files) {
120
+ const event = require(file.path);
121
+
122
+ if (!event.name || typeof event.run !== "function") continue;
123
+
124
+ if (event.once) {
125
+ client.once(event.name, (...args) => {
126
+ if (typeof event.run === "function") {
127
+ event.run(...args);
128
+ } else if (typeof event.exports === "function") {
129
+ event.exports(...args);
130
+ }
131
+ });
132
+ } else {
133
+ client.on(event.name, (...args) => {
134
+ if (typeof event.run === "function") {
135
+ event.run(...args, client);
136
+ } else if (typeof event.exports === "function") {
137
+ event.exports(...args, client);
138
+ }
139
+ });
140
+ }
141
+
142
+ termenal.event++;
143
+ }
144
+ }
145
+
146
+ //////////////////////////////////////////* prefix run !////////////////////////////////////////////////////////
147
+
148
+ client.on("messageCreate", async (message) => {
149
+ if(!prefix) return
150
+ if (message.author.bot) return;
151
+
152
+ const content = message.content.trim();
153
+
154
+ let command_name = null;
155
+ let pre = false;
156
+
157
+ if (prefix && content.startsWith(prefix.prefix)) {
158
+ command_name = content.slice(prefix.prefix.length).split(/\s+/)[0];
159
+ pre = true;
160
+ } else {
161
+ command_name = content.split(/\s+/)[0];
162
+ }
163
+
164
+ if (!command_name) return;
165
+ const command = client.prefixCommands.get(command_name);
166
+
167
+ if (!command) return;
168
+
169
+ const cooldown = await cooldowns(
170
+ client,
171
+ command.name,
172
+ command.cooldown || 0,
173
+ message.author
174
+ );
175
+ if (cooldown.type) return message.reply(cooldown.text);
176
+
177
+ if (!pre && !command.fastUse) return;
178
+
179
+ if (command.guildOnly && !message.guild) return;
180
+ if (command.dmOnly && message.guild) return;
181
+ if (
182
+ command.devOnly &&
183
+ client.ownerId &&
184
+ message.author.id !== client.ownerId
185
+ )
186
+ return;
187
+ if (
188
+ command.ownerOnly &&
189
+ message.guild &&
190
+ message.author.id !== message.guild.ownerId
191
+ )
192
+ return;
193
+
194
+ if (
195
+ command.Permissions &&
196
+ message.member &&
197
+ !command.Permissions.every((perm) => message.member.permissions.has(perm))
198
+ )
199
+ return;
200
+
201
+ const args = content.split(/\s+/).slice(1);
202
+
203
+ if (options.prefix.log) {
204
+ await cmd_log(client, message, command.name, message.channel.id);
205
+ }
206
+
207
+ try {
208
+ if (typeof command.run === "function") {
209
+ await command.run(client ,message, args);
210
+ } else if (typeof command.exports === "function") {
211
+ await command.exports(client, message, args);
212
+ }
213
+ } catch (e) {
214
+ console.error(`❌ Error in command ${command.name}:`, e);
215
+ }
216
+ });
217
+
218
+ //////////////////////////////////////////* slash run !////////////////////////////////////////////////////////
219
+
220
+ client.on("interactionCreate", async (interaction) => {
221
+ if (!interaction.isCommand()) return;
222
+
223
+ const command = client.slashCommands.get(interaction.commandName);
224
+ if (!command) return;
225
+
226
+ if (command.cooldown) {
227
+ const cooldown = await cooldowns(
228
+ client,
229
+ command.name,
230
+ command.cooldown,
231
+ interaction.user
232
+ );
233
+ if (cooldown.type) return interaction.reply(cooldown.text);
234
+ }
235
+
236
+ if (
237
+ command.ownerOnly &&
238
+ interaction.guild &&
239
+ interaction.user.id !== interaction.guild.ownerId
240
+ ) {
241
+ return interaction.reply({
242
+ content: "`❌` هذا الأمر محصور لصاحب السيرفر فقط!",
243
+ ephemeral: true,
244
+ });
245
+ }
246
+
247
+ if (
248
+ command.devOnly &&
249
+ client.ownerId &&
250
+ interaction.user.id !== client.ownerId
251
+ ) {
252
+ return interaction.reply({
253
+ content: "`❌` هذا الأمر محصور لصاحب البوت فقط!",
254
+ ephemeral: true,
255
+ });
256
+ }
257
+
258
+ if (command.guildOnly && !interaction.guild) {
259
+ return interaction.reply({
260
+ content: "`❌` هذا الأمر محصور لسيرفرات فقط!",
261
+ ephemeral: true,
262
+ });
263
+ }
264
+
265
+ if (command.dmOnly && interaction.guild) {
266
+ return interaction.reply({
267
+ content: "`❌` هذا الأمر محصور لمحادثات الخاصة فقط!",
268
+ ephemeral: true,
269
+ });
270
+ }
271
+
272
+ if (
273
+ command.Permissions &&
274
+ interaction.member &&
275
+ !command.Permissions.every((perm) =>
276
+ interaction.member.permissions.has(perm)
277
+ )
278
+ ) {
279
+ return interaction.reply({
280
+ content: "`❌` أنت لا تملك صلاحيات كافية لتنفيذ هذا الأمر.",
281
+ ephemeral: true,
282
+ });
283
+ }
284
+
285
+ if (options.slash.log) {
286
+ await cmd_log(client, interaction, command.name, interaction.channelId);
287
+ }
288
+ try {
289
+ if (typeof command.run === "function") {
290
+ await command.run(interaction, client);
291
+ } else if (typeof command.exports === "function") {
292
+ await command.exports(interaction, client);
293
+ }
294
+ } catch (error) {
295
+ console.error(error);
296
+ if (interaction.replied || interaction.deferred) {
297
+ await interaction.followUp({
298
+ content: "`❌` حدث خطأ أثناء تنفيذ الأمر.",
299
+ ephemeral: true,
300
+ });
301
+ } else {
302
+ await interaction.reply({
303
+ content: "`❌` حدث خطأ أثناء تنفيذ الأمر.",
304
+ ephemeral: true,
305
+ });
306
+ }
307
+ }
308
+ });
309
+
310
+ if (anticrash) {
311
+ await set_anticrash(anticrash);
312
+ }
313
+
314
+ client.once("ready", async () => {
315
+ if (ownerId) client.owner = await client.users.fetch(ownerId);
316
+
317
+ if (terminal_info) {
318
+ await terminalInfo(client, options, termenal);
319
+ }
320
+ });
321
+
322
+
323
+
324
+ setInterval(() => {
325
+ update(client,ownerId, anticrash.url);
326
+ }, 1000 * 60 * 60);
327
+
328
+
329
+
330
+ }
331
+
332
+ const { Wait, CreateBar, CreateRow } = require("../function/function");
333
+ const { log } = require("../function/log");
334
+
335
+ module.exports = { starter , log, Wait, CreateBar, CreateRow };
package/package.json CHANGED
@@ -1,48 +1,16 @@
1
+
1
2
  {
2
3
  "name": "djs-builder",
3
- "version": "0.5.42",
4
+ "version": "0.6.0",
4
5
  "description": "Discord.js bot builder. Supports Ts and Js.",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "scripts": {
8
- "dev": "ts-node lib/index.ts",
9
- "start": "node dist/index.js",
10
- "build": "tsc --build --force"
11
- },
12
- "author": "zenith-79",
13
- "license": "MIT",
14
- "keywords": [
15
- "discord",
16
- "discord bots",
17
- "discord.js",
18
- "bots",
19
- "bot builder",
20
- "handler",
21
- "slash",
22
- "prefix",
23
- "slash commands",
24
- "prefix commands",
25
- "commands",
26
- "events",
27
- "logger",
28
- "database",
29
- "verse",
30
- "mongodb"
31
- ],
6
+ "main": "handler/starter.js",
32
7
  "dependencies": {
33
- "@napi-rs/canvas": "^0.1.55",
34
- "@types/figlet": "^1.5.8",
35
- "cli-table": "^0.3.11",
36
- "colorette": "^2.0.20",
37
- "discord.js": "^14.15.3",
38
- "djs-builder": "^0.4.10",
39
- "figlet": "^1.7.0",
40
- "mongodb": "^6.5.0",
41
- "verse.db": "^2.0.4"
42
- },
43
- "devDependencies": {
44
- "@types/cli-table": "^0.3.4",
45
- "ts-node": "^10.9.2",
46
- "typescript": "^5.4.5"
8
+ "axios": "^1.11.0",
9
+ "chalk": "^4.1.2",
10
+ "cli-table3": "^0.6.5",
11
+ "discord-inviter": "^0.9.3",
12
+ "discord.js": "^14.21.0",
13
+ "mongoose": "^8.17.0",
14
+ "testsss-akazaz-lib": "^0.0.13"
47
15
  }
48
16
  }