djs-builder 0.6.8 → 0.6.10

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/handler/helper.js CHANGED
@@ -194,40 +194,86 @@ async function set_anticrash(data) {
194
194
  async function cmd_log(client, data, commandName, channelId) {
195
195
  const isSlash = !!data.user;
196
196
  const user = isSlash ? data.user : data.author;
197
- const channel = data.guild ? `Channel: ${data.channel.name} | ${data.channel} (${data.channel.id})\n Guild: ${data.guild.name} | (${data.guild.id})` : "DM";
198
- const messageUrl = data.message?.url || "`not found`";
199
197
 
200
198
  const logChannel = client.channels.cache.get(channelId);
201
199
  if (!logChannel) return;
202
200
 
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}\`` },
201
+ const field = [
202
+ {
203
+ name: "📧 Cmd:",
204
+ value: `- ${commandName}`,
205
+ inline: true,
206
+ },
207
+ {
208
+ name: "👤 User:",
209
+ value: `- ${user?.tag ?? "Unknown user"} | (\`${user?.id ?? "Unknown ID"}\`)`,
210
+ inline: true,
211
+ },
212
+ {
213
+ name: "\u200B",
214
+ value: "\u200B",
215
+ inline: true,
216
+ },
217
+ ];
218
+
219
+ if (data.guild && data.channel) {
220
+ field.push(
208
221
  {
209
- name: "👤 User",
210
- value: `${user.tag || user.username} | ${user} (${user.id})`,
211
-
222
+ name: "🏠 Server:",
223
+ value: `- ${data.guild.name} | (\`${data.guild.id}\`)`,
224
+ inline: true,
212
225
  },
213
- { name: "💬 Channel", value: `${channel}` },
214
- { name: "🔗 Message", value: `[Link](${messageUrl})` },
215
226
  {
216
- name: "🕒 Date",
217
- value: `<t:${Math.floor(Date.now() / 1000)}:F>`,
227
+ name: "💬 Channel",
228
+ value: `- ${data.channel.name} | (\`${data.channel.id}\`)`,
229
+ inline: true,
230
+ },
231
+ {
232
+ name: "\u200B",
233
+ value: "\u200B",
234
+ inline: true,
235
+ },
236
+ {
237
+ name: "🔗 Message",
238
+ value:
239
+ data.message && data.message.url
240
+ ? `- [Link](${data.message.url})`
241
+ : "not found",
218
242
  inline: true,
219
243
  }
220
- )
244
+ );
245
+ } else if (!data.guild) {
246
+ field.push({
247
+ name: "👀 DM Message",
248
+ value: `${user?.tag ?? "Unknown user"}`,
249
+ inline: true,
250
+ });
251
+ }
252
+
253
+ field.push({
254
+ name: "⏳ Date:",
255
+ value: `<t:${Math.floor(Date.now() / 1000)}:F>`,
256
+ });
257
+
258
+ const embed = new EmbedBuilder()
259
+ .setTitle(isSlash ? "📘 Slash Command Log" : "📗 Prefix Command Log")
260
+ .setColor(isSlash ? "Green" : "Blue")
261
+ .addFields(...field)
221
262
  .setThumbnail(client.user.displayAvatarURL({ dynamic: true }))
222
263
  .setAuthor({
223
- name : `${user.tag} || ${user.username}`,
224
- iconURL: user.displayAvatarURL({ dynamic: true }),
264
+ name: `${user?.tag ?? "Unknown user"} || ${user?.username ?? "Unknown"}`,
265
+ iconURL: user?.displayAvatarURL({ dynamic: true }),
225
266
  })
226
267
  .setTimestamp();
227
268
 
228
- logChannel.send({ embeds: [embed] }).catch(console.error);
269
+ try {
270
+ await logChannel.send({ embeds: [embed] });
271
+ } catch (error) {
272
+ console.error("Error sending log embed:", error);
273
+ }
229
274
  }
230
275
 
276
+
231
277
  //////////////////////////////////* Check update 🔼
232
278
 
233
279
  async function update(client, id, webhookURL) {
@@ -4,7 +4,7 @@ const {
4
4
  terminalInfo,
5
5
  set_anticrash,
6
6
  cmd_log,
7
- update
7
+ update,
8
8
  } = require("./helper");
9
9
  let termenal = {
10
10
  prefix: 0,
@@ -103,17 +103,16 @@ async function starter(client, options) {
103
103
  const slash_files = await readFile(slash.path);
104
104
  const validSlashCommands = slash_files
105
105
  .map((f) => require(f.path))
106
- .filter((cmd) => cmd.data && (typeof cmd.run === "function" || typeof cmd.execute === "function"));
106
+ .filter(
107
+ (cmd) =>
108
+ cmd.data &&
109
+ (typeof cmd.run === "function" || typeof cmd.execute === "function")
110
+ );
107
111
 
108
-
109
112
  client.slashCommands = new Map(
110
113
  validSlashCommands.map((cmd) => [cmd.data.name, cmd])
111
114
  );
112
-
113
-
114
- const slashData = validSlashCommands.map(cmd => cmd.data.toJSON());
115
-
116
- await client.application.commands.set(slashData);
115
+ client.slashData = validSlashCommands.map((cmd) => cmd.data.toJSON());
117
116
 
118
117
  termenal.slash = validSlashCommands.length;
119
118
  }
@@ -152,7 +151,6 @@ async function starter(client, options) {
152
151
  //////////////////////////////////////////* prefix run !////////////////////////////////////////////////////////
153
152
 
154
153
  client.on("messageCreate", async (message) => {
155
-
156
154
  if (message.author.bot) return;
157
155
 
158
156
  const content = message.content.trim();
@@ -212,7 +210,7 @@ async function starter(client, options) {
212
210
 
213
211
  try {
214
212
  if (typeof command.run === "function") {
215
- await command.run(client ,message, args);
213
+ await command.run(client, message, args);
216
214
  } else if (typeof command.execute === "function") {
217
215
  await command.execute(client, message, args);
218
216
  }
@@ -289,7 +287,12 @@ async function starter(client, options) {
289
287
  }
290
288
 
291
289
  if (options.slash.log) {
292
- await cmd_log(client, interaction, interaction.commandName, options.slash.log);
290
+ await cmd_log(
291
+ client,
292
+ interaction,
293
+ interaction.commandName,
294
+ options.slash.log
295
+ );
293
296
  }
294
297
  try {
295
298
  if (typeof command.run === "function") {
@@ -319,23 +322,21 @@ async function starter(client, options) {
319
322
 
320
323
  client.once("ready", async () => {
321
324
  if (ownerId) client.owner = await client.users.fetch(ownerId);
325
+ if (client.slashData?.length) {
326
+ await client.application.commands.set(client.slashData);
327
+ }
322
328
 
323
329
  if (terminal_info) {
324
330
  await terminalInfo(client, options, termenal);
325
331
  }
326
332
  });
327
333
 
328
-
329
-
330
- setInterval(() => {
331
- update(client,ownerId, anticrash.url);
332
- }, 1000 * 60 * 60);
333
-
334
-
335
-
334
+ setInterval(() => {
335
+ update(client, ownerId, anticrash.url);
336
+ }, 1000 * 60 * 60);
336
337
  }
337
338
 
338
339
  const { Wait, CreateBar, CreateRow } = require("../function/function");
339
340
  const { log } = require("../function/log");
340
341
 
341
- module.exports = { starter , log, Wait, CreateBar, CreateRow };
342
+ module.exports = { starter, log, Wait, CreateBar, CreateRow };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  {
3
3
  "name": "djs-builder",
4
- "version": "0.6.8",
4
+ "version": "0.6.10",
5
5
  "description": "Discord.js bot builder. Supports Ts and Js.",
6
6
  "main": "handler/starter.js",
7
7
  "dependencies": {