djs-builder 0.6.9 → 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,14 +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"));
107
-
108
-
109
- client.slashCommands = new Map(validSlashCommands.map(cmd => [cmd.data.name, cmd]));
110
- client.slashData = validSlashCommands.map(cmd => cmd.data.toJSON());
111
-
106
+ .filter(
107
+ (cmd) =>
108
+ cmd.data &&
109
+ (typeof cmd.run === "function" || typeof cmd.execute === "function")
110
+ );
112
111
 
113
-
112
+ client.slashCommands = new Map(
113
+ validSlashCommands.map((cmd) => [cmd.data.name, cmd])
114
+ );
115
+ client.slashData = validSlashCommands.map((cmd) => cmd.data.toJSON());
114
116
 
115
117
  termenal.slash = validSlashCommands.length;
116
118
  }
@@ -149,7 +151,6 @@ client.slashData = validSlashCommands.map(cmd => cmd.data.toJSON());
149
151
  //////////////////////////////////////////* prefix run !////////////////////////////////////////////////////////
150
152
 
151
153
  client.on("messageCreate", async (message) => {
152
-
153
154
  if (message.author.bot) return;
154
155
 
155
156
  const content = message.content.trim();
@@ -209,7 +210,7 @@ client.slashData = validSlashCommands.map(cmd => cmd.data.toJSON());
209
210
 
210
211
  try {
211
212
  if (typeof command.run === "function") {
212
- await command.run(client ,message, args);
213
+ await command.run(client, message, args);
213
214
  } else if (typeof command.execute === "function") {
214
215
  await command.execute(client, message, args);
215
216
  }
@@ -286,7 +287,12 @@ client.slashData = validSlashCommands.map(cmd => cmd.data.toJSON());
286
287
  }
287
288
 
288
289
  if (options.slash.log) {
289
- 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
+ );
290
296
  }
291
297
  try {
292
298
  if (typeof command.run === "function") {
@@ -316,26 +322,21 @@ client.slashData = validSlashCommands.map(cmd => cmd.data.toJSON());
316
322
 
317
323
  client.once("ready", async () => {
318
324
  if (ownerId) client.owner = await client.users.fetch(ownerId);
319
- if (client.slashData?.length) {
320
- await client.application.commands.set(client.slashData);
321
- }
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.9",
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": {