xernerx 2.0.4 → 2.0.5

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.
@@ -7,24 +7,25 @@ module.exports = function commandValidation(event, command, res = false) {
7
7
  function emit(reason, extra) {
8
8
  return event.client.emit('commandBlocked', event, reason, extra);
9
9
  }
10
- if ((command.ignoreOwner || event.client.ignoreOwner) && event.client.ownerId.includes((event.user || event.author).id)) return res;
10
+
11
+ if ((command?.ignoreOwner || event?.client?.settings?.ignoreOwner) && event?.client?.settings?.ownerId?.includes((event.user || event.author).id)) return res;
11
12
 
12
13
  if (Cooldown[(event.user || event.author).id]) {
13
14
  res = true;
14
- return emit("command on cooldown", (Cooldown[(event.user || event.author).id] - event.createdTimestamp));
15
+ return emit("command on cooldown", (Cooldown[(event.user || event.author).id] - (event.editedTimestamp || event.createdTimestamp)));
15
16
  }
16
17
 
17
18
  if (!Cooldown[(event.user || event.author).id]) {
18
- Cooldown[(event.user || event.author).id] = (event.createdTimestamp + (command.cooldown || event.client.settings.defaultCooldown || 0));
19
+ Cooldown[(event.user || event.author).id] = ((event.editedTimestamp || event.createdTimestamp) + (command.cooldown || event.client.settings.defaultCooldown || 0));
19
20
 
20
21
  setTimeout(() => {
21
22
  delete Cooldown[(event.user || event.author).id]
22
- }, command.cooldown || event.client.settings.defaultCooldown || 0)
23
+ }, command.cooldown || event?.client?.settings?.defaultCooldown || 0);
23
24
  }
24
25
 
25
- if (command?.owner && event?.client?.ownerId != undefined && !event?.client?.ownerId?.includes((event.user || event.author).id)) {
26
+ if (command?.owner && event?.client?.settings?.ownerId != undefined && !event?.client?.settings?.ownerId?.includes((event.user || event.author).id)) {
26
27
  res = true;
27
- return emit("missing ownership", client.ownerId)
28
+ return emit("missing ownership", event?.client?.settings?.ownerId)
28
29
  }
29
30
 
30
31
  if (command?.admin && event?.member?.permissions?.has(Discord.PermissionFlagsBits.Administrator) == false) {
@@ -47,14 +48,14 @@ module.exports = function commandValidation(event, command, res = false) {
47
48
  return emit("not a in a voice channel");
48
49
  }
49
50
 
50
- if (event?.guild && command?.userPermissions.length >= 1 || event?.client?.settings?.userPermissions.length >= 1) {
51
+ if (event?.guild && command?.userPermissions?.length >= 1 || event?.client?.settings?.userPermissions?.length >= 1) {
51
52
  let missingPerms = [];
52
53
 
53
54
  for (const permission of command.userPermissions) {
54
55
  if (!event?.member?.permissions?.has(Discord.PermissionFlagsBits[toPascalCase(permission)])) missingPerms.push(toPascalCase(permission));
55
56
  }
56
57
 
57
- for (const permission of event.client.settings.userPermissions) {
58
+ for (const permission of event?.client?.settings?.userPermissions) {
58
59
  if (!event?.member?.permissions?.has(Discord.PermissionFlagsBits[toPascalCase(permission)])) missingPerms.push(toPascalCase(permission));
59
60
  }
60
61
 
@@ -67,11 +68,11 @@ module.exports = function commandValidation(event, command, res = false) {
67
68
  if (event?.guild && command?.clientPermissions.length >= 1 || event.client.settings.clientPermissions.length >= 1) {
68
69
  let missingPerms = [];
69
70
 
70
- for (const permission of command.clientPermissions) {
71
+ for (const permission of command?.clientPermissions) {
71
72
  if (!event?.guild?.members?.me?.permissions?.has(Discord.PermissionFlagsBits[toPascalCase(permission)])) missingPerms.push(toPascalCase(permission));
72
73
  }
73
74
 
74
- for (const permission of event.client.settings.clientPermissions) {
75
+ for (const permission of event?.client?.settings?.clientPermissions) {
75
76
  if (!event?.guild?.members?.me?.permissions?.has(Discord.PermissionFlagsBits[toPascalCase(permission)])) missingPerms.push(toPascalCase(permission));
76
77
  }
77
78
 
@@ -81,12 +82,12 @@ module.exports = function commandValidation(event, command, res = false) {
81
82
  }
82
83
  }
83
84
 
84
- if (command.guilds.length >= 1 && !command?.guilds?.includes(event.guild)) {
85
+ if (command?.guilds?.length >= 1 && !command?.guilds?.includes(event.guild)) {
85
86
  res = true;
86
87
  return emit('not in a specified guild', command.guilds);
87
88
  }
88
89
 
89
- if (command.channels.length >= 1 && !command?.channels?.includes(event.channel.id)) {
90
+ if (command?.channels?.length >= 1 && !command?.channels?.includes(event.channel.id)) {
90
91
  res = true;
91
92
  return emit('not in a specified channel', command.channels);
92
93
  }
@@ -46,7 +46,7 @@ class CommandHandler {
46
46
 
47
47
  this.#deployCommands("interaction commands", logging);
48
48
 
49
- if (logging || this.client.logging) console.info(logStyle(`Loading interaction commands: ${commands.join(', ')}`, "text", "yellow"));
49
+ if (logging || this.client.settings.logging) console.info(logStyle(`Loading interaction commands: ${commands.join(', ')}`, "text", "yellow"));
50
50
  }
51
51
 
52
52
  loadAllContextMenuCommands(path, logging = false) {
@@ -72,7 +72,7 @@ class CommandHandler {
72
72
 
73
73
  this.#deployCommands("context menu commands", logging);
74
74
 
75
- if (logging || this.client.logging) console.info(logStyle(`Loading context menu commands: ${commands.join(', ')}`, 'text', 'yellow'));
75
+ if (logging || this.client.settings.logging) console.info(logStyle(`Loading context menu commands: ${commands.join(', ')}`, 'text', 'yellow'));
76
76
  }
77
77
 
78
78
  loadAllMessageCommands(path, logging = false) {
@@ -98,7 +98,7 @@ class CommandHandler {
98
98
  commands.push(command.name || command.id);
99
99
  }
100
100
 
101
- if (logging || this.client.logging) console.info(logStyle(`Loaded message commands: ${commands.join(', ')}`, 'text', 'purple'));
101
+ if (logging || this.client.settings.logging) console.info(logStyle(`Loaded message commands: ${commands.join(', ')}`, 'text', 'purple'));
102
102
  }
103
103
 
104
104
  #deployCommands(type, logging = false) {
@@ -106,15 +106,17 @@ class CommandHandler {
106
106
  const rest = new REST({ version: GatewayVersion }).setToken(client.token);
107
107
 
108
108
  (async () => {
109
+ if (type === "interaction commands" && client.settings.logging) console.log(logStyle(`${client.user.tag} is online in ${(await client.guilds.fetch()).size} servers.`, "text", "cyan"));
110
+
109
111
  try {
110
112
  if (client.global == true) {
111
- if (logging || this.client.logging) console.info(logStyle(`Loaded ${type} in ${(await client.guilds.fetch()).size} server(s) globally.`, 'text', 'purple'));
113
+ if (logging || this.client.settings.logging) console.info(logStyle(`Loaded ${type} in ${(await client.guilds.fetch()).size} server(s) globally.`, 'text', 'purple'));
112
114
  rest.put(Routes.applicationCommands(client.user.id), {
113
115
  body: this.commands
114
116
  })
115
117
  }
116
118
  else {
117
- if (logging || this.client.logging) console.info(logStyle(`Loaded ${type} locally.`, 'text', 'purple'));
119
+ if (logging || this.client.settings.logging) console.info(logStyle(`Loaded ${type} locally.`, 'text', 'purple'));
118
120
  rest.put(Routes.applicationGuildCommands(client.user.id, client.settings.guildId), {
119
121
  body: this.commands
120
122
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xernerx",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "A bot framework for discord.js. [BETA]",
5
5
  "main": "main.js",
6
6
  "scripts": {