xernerx 3.3.6 → 3.4.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 (79) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +21 -21
  3. package/dist/build/ContextCommandBuilder.d.ts +6 -4
  4. package/dist/build/ContextCommandBuilder.js +8 -4
  5. package/dist/build/EventBuilder.d.ts +2 -2
  6. package/dist/build/EventBuilder.js +4 -4
  7. package/dist/build/InhibitorBuilder.d.ts +4 -3
  8. package/dist/build/InhibitorBuilder.js +2 -2
  9. package/dist/build/MessageCommandBuilder.d.ts +1 -1
  10. package/dist/build/MessageCommandBuilder.js +2 -2
  11. package/dist/build/SlashCommandBuilder.d.ts +7 -3
  12. package/dist/build/SlashCommandBuilder.js +21 -13
  13. package/dist/build/{ContextCommand.d.ts → XContextCommandBuilder.d.ts} +5 -5
  14. package/dist/build/{ContextCommand.js → XContextCommandBuilder.js} +5 -5
  15. package/dist/build/{Event.d.ts → XEventBuilder.d.ts} +3 -3
  16. package/dist/build/{Event.js → XEventBuilder.js} +5 -5
  17. package/dist/build/XInhibitorBuilder.d.ts +20 -0
  18. package/dist/build/{Inhibitor.js → XInhibitorBuilder.js} +4 -4
  19. package/dist/build/{MessageCommand.d.ts → XMessageCommandBuilder.d.ts} +8 -7
  20. package/dist/build/{MessageCommand.js → XMessageCommandBuilder.js} +9 -11
  21. package/dist/build/{SlashCommand.d.ts → XSlashCommandBuilder.d.ts} +4 -4
  22. package/dist/build/{SlashCommand.js → XSlashCommandBuilder.js} +13 -24
  23. package/dist/client/XernerxClient.d.ts +1 -1
  24. package/dist/client/XernerxClient.js +1 -2
  25. package/dist/handlers/CommandHandler.d.ts +4 -5
  26. package/dist/handlers/CommandHandler.js +2 -2
  27. package/dist/handlers/EventHandler.d.ts +4 -5
  28. package/dist/handlers/EventHandler.js +1 -1
  29. package/dist/handlers/Handler.d.ts +25 -6
  30. package/dist/handlers/Handler.js +41 -36
  31. package/dist/handlers/InhibitorHandler.d.ts +2 -3
  32. package/dist/main.d.ts +5 -71
  33. package/dist/main.js +7 -12
  34. package/dist/models/CommandArguments.d.ts +2 -2
  35. package/dist/models/CommandArguments.js +4 -2
  36. package/dist/models/CommandValidations.d.ts +3 -3
  37. package/dist/models/CommandValidations.js +26 -28
  38. package/dist/models/Events.d.ts +5 -5
  39. package/dist/models/Events.js +77 -30
  40. package/dist/models/Extensions.d.ts +4 -3
  41. package/dist/models/Extensions.js +5 -3
  42. package/dist/tools/package.d.ts +38 -0
  43. package/dist/tools/package.js +37 -0
  44. package/dist/types/enums.js +4 -4
  45. package/dist/types/options.d.ts +3 -2
  46. package/dist/types/{Types.d.ts → types.d.ts} +0 -0
  47. package/dist/{interfaces/ClientInterfaces.js → types/types.js} +0 -0
  48. package/dist/utils/ClientUtil.d.ts +1 -1
  49. package/dist/utils/ClientUtil.js +0 -11
  50. package/dist/utils/CommandUtil.d.ts +12 -6
  51. package/dist/utils/CommandUtil.js +26 -14
  52. package/dist/validators/CommandValidations.d.ts +7 -0
  53. package/dist/validators/CommandValidations.js +185 -0
  54. package/dist/validators/InhibitorValidations.d.ts +11 -0
  55. package/dist/validators/InhibitorValidations.js +42 -0
  56. package/package.json +7 -6
  57. package/dist/build/ExtensionBuilder.d.ts +0 -7
  58. package/dist/build/ExtensionBuilder.js +0 -9
  59. package/dist/build/Inhibitor.d.ts +0 -18
  60. package/dist/build/XernerxExtension.d.ts +0 -7
  61. package/dist/build/XernerxExtension.js +0 -9
  62. package/dist/handlers/WebhookHandler.d.ts +0 -12
  63. package/dist/handlers/WebhookHandler.js +0 -36
  64. package/dist/interfaces/ClientInterfaces.d.ts +0 -65
  65. package/dist/interfaces/CommandInterfaces.d.ts +0 -94
  66. package/dist/interfaces/CommandInterfaces.js +0 -1
  67. package/dist/interfaces/HandlerInterfaces.d.ts +0 -62
  68. package/dist/interfaces/HandlerInterfaces.js +0 -1
  69. package/dist/models/Functions.d.ts +0 -1
  70. package/dist/models/Functions.js +0 -1
  71. package/dist/types/EventTypes.d.ts +0 -1
  72. package/dist/types/EventTypes.js +0 -1
  73. package/dist/types/InhibitorTypes.d.ts +0 -12
  74. package/dist/types/InhibitorTypes.js +0 -13
  75. package/dist/types/Types.js +0 -1
  76. package/dist/types/objects.d.ts +0 -18
  77. package/dist/types/objects.js +0 -1
  78. package/scripts/package.d.ts +0 -1
  79. package/scripts/package.js +0 -3
@@ -1,5 +1,5 @@
1
- import { Message } from "discord.js";
2
- import { CommandType } from "../types/enums.js";
1
+ import { Message } from 'discord.js';
2
+ import { CommandType } from '../types/enums.js';
3
3
  function getUser(from) {
4
4
  if (from instanceof Message)
5
5
  return from.author;
@@ -14,26 +14,30 @@ export default function commandValidation(action, command, client, res = false)
14
14
  return true;
15
15
  else if (command.owner && !client.util.isOwner(user.id)) {
16
16
  res = true;
17
- emit(client, action, command, "Not an owner", client.settings.ownerId);
17
+ emit(client, action, command, 'Not an owner', client.settings.ownerId);
18
18
  }
19
19
  else if (command.channelType?.length > 0 || command.channelType) {
20
20
  if (!Array.isArray(command.channelType))
21
21
  command.channelType = [command.channelType];
22
22
  if (!command?.channelType?.includes(action.channel?.type)) {
23
23
  res = true;
24
- emit(client, action, command, "Not the correct channel", command.channelType);
24
+ emit(client, action, command, 'Not the correct channel', command.channelType);
25
25
  }
26
26
  }
27
27
  else if (command.channels?.length > 0 && !command.channels.includes(action.channel?.id)) {
28
28
  res = true;
29
- emit(client, action, command, "Not a whitelisted channel", command.channels);
29
+ emit(client, action, command, 'Not a whitelisted channel', command.channels);
30
30
  }
31
31
  else if (command.guilds?.length > 0 && !command.guilds.includes(action.guild?.id)) {
32
32
  res = true;
33
- emit(client, action, command, "Not a whitelisted guild", command.guilds);
33
+ emit(client, action, command, 'Not a whitelisted guild', command.guilds);
34
+ }
35
+ else if (command.channelType && command.channelType !== action.channel?.type) {
36
+ res = true;
37
+ emit(client, action, command, 'Not the correct type of channel', command.channelType);
34
38
  }
35
39
  else if (action?.guild && (command.userPermissions || client.settings.userPermissions)) {
36
- const permissions = command.userPermissions || client?.settings?.userPermissions?.push(...handlerPermissions(client, command.commandType, "user")), missing = [];
40
+ const permissions = command.userPermissions || client?.settings?.userPermissions?.push(...handlerPermissions(client, command.commandType, 'user')), missing = [];
37
41
  if (Array.isArray(permissions))
38
42
  permissions.map((permission) => {
39
43
  if (!(action.member?.permissions).has(permission)) {
@@ -42,11 +46,11 @@ export default function commandValidation(action, command, client, res = false)
42
46
  });
43
47
  if (missing.length > 0) {
44
48
  res = true;
45
- emit(client, action, command, "Missing User Permissions", missing);
49
+ emit(client, action, command, 'Missing User Permissions', missing);
46
50
  }
47
51
  }
48
52
  else if (action?.guild && (command.clientPermissions || client.settings.clientPermissions)) {
49
- const permissions = command.clientPermissions || client?.settings?.clientPermissions?.push(...handlerPermissions(client, command.commandType, "client")), missing = [];
53
+ const permissions = command.clientPermissions || client?.settings?.clientPermissions?.push(...handlerPermissions(client, command.commandType, 'client')), missing = [];
50
54
  if (Array.isArray(permissions))
51
55
  permissions.map((permission) => {
52
56
  if (!(action.member?.permissions).has(permission)) {
@@ -55,17 +59,17 @@ export default function commandValidation(action, command, client, res = false)
55
59
  });
56
60
  if (missing.length > 0) {
57
61
  res = true;
58
- emit(client, action, command, "Missing Client Permissions", missing);
62
+ emit(client, action, command, 'Missing Client Permissions', missing);
59
63
  }
60
64
  }
61
65
  return res;
62
66
  }
63
67
  function emit(client, action, command, reason, extra) {
64
- return client.emit("commandBlock", action, command, reason, extra);
68
+ return client.emit('commandBlock', action, command, reason, extra);
65
69
  }
66
70
  function inCooldown(user, client, command, action) {
67
71
  let res = false, downs = {};
68
- const { cooldowns, messageCommands, slashCommands, contextCommands, commands, } = client.cache;
72
+ const { cooldowns, messageCommands, slashCommands, contextCommands, commands } = client.cache;
69
73
  if (command.commandType === CommandType.MessageCommand && client.handlerOptions.message.cooldown) {
70
74
  if (messageCommands.has(user.id)) {
71
75
  const usr = messageCommands.get(user.id);
@@ -80,8 +84,7 @@ function inCooldown(user, client, command, action) {
80
84
  }, client.handlerOptions.message.cooldown);
81
85
  }
82
86
  }
83
- if (command.commandType === CommandType.SlashCommand &&
84
- client.handlerOptions.slash.cooldown) {
87
+ if (command.commandType === CommandType.SlashCommand && client.handlerOptions.slash.cooldown) {
85
88
  if (slashCommands.has(user.id)) {
86
89
  const usr = slashCommands.get(user.id);
87
90
  usr.timeRemaining = usr.endsAt - Date.now();
@@ -95,8 +98,7 @@ function inCooldown(user, client, command, action) {
95
98
  }, client.handlerOptions.slash.cooldown);
96
99
  }
97
100
  }
98
- if (command.commandType === CommandType.ContextCommand &&
99
- client.handlerOptions.context.cooldown) {
101
+ if (command.commandType === CommandType.ContextCommand && client.handlerOptions.context.cooldown) {
100
102
  if (contextCommands.has(user.id)) {
101
103
  const usr = contextCommands.get(user.id);
102
104
  usr.timeRemaining = usr.endsAt - Date.now();
@@ -125,11 +127,7 @@ function inCooldown(user, client, command, action) {
125
127
  }
126
128
  }
127
129
  if (command.cooldown) {
128
- const name = user.id +
129
- "-" +
130
- (command.data?.name || command?.name) +
131
- "-" +
132
- command.commandType;
130
+ const name = user.id + '-' + (command.data?.name || command?.name) + '-' + command.commandType;
133
131
  if (commands.has(name)) {
134
132
  const usr = commands.get(name);
135
133
  usr.timeRemaining = usr.endsAt - Date.now();
@@ -144,7 +142,7 @@ function inCooldown(user, client, command, action) {
144
142
  }
145
143
  }
146
144
  if (Object.keys(downs).length > 0)
147
- client.emit("commandCooldown", action, command, downs);
145
+ client.emit('commandCooldown', action, command, downs);
148
146
  return res;
149
147
  }
150
148
  function toCooldown(action, command, cooldown, name) {
@@ -164,21 +162,21 @@ function toCooldown(action, command, cooldown, name) {
164
162
  function handlerPermissions(client, commandType, type) {
165
163
  let permissions = [];
166
164
  if (commandType === CommandType.MessageCommand) {
167
- if (type === "user")
165
+ if (type === 'user')
168
166
  permissions = client.handlerOptions.message?.userPermissions || [];
169
- else if (type === "client")
167
+ else if (type === 'client')
170
168
  permissions = client.handlerOptions.message?.clientPermissions || [];
171
169
  }
172
170
  else if (commandType === CommandType.SlashCommand) {
173
- if (type === "user")
171
+ if (type === 'user')
174
172
  permissions = client.handlerOptions.slash?.userPermissions || [];
175
- else if (type === "client")
173
+ else if (type === 'client')
176
174
  permissions = client.handlerOptions.slash?.clientPermissions || [];
177
175
  }
178
176
  else if (commandType === CommandType.ContextCommand) {
179
- if (type === "user")
177
+ if (type === 'user')
180
178
  permissions = client.handlerOptions.context?.userPermissions || [];
181
- else if (type === "client")
179
+ else if (type === 'client')
182
180
  permissions = client.handlerOptions.context?.clientPermissions || [];
183
181
  }
184
182
  return permissions;
@@ -1,24 +1,24 @@
1
1
  import XernerxClient from '../client/XernerxClient.js';
2
2
  export declare class MessageCommandEvents {
3
- client: XernerxClient;
3
+ private client;
4
4
  constructor(client: XernerxClient);
5
5
  messageCreate(): void;
6
6
  messageUpdate(): void;
7
7
  messageDelete(): void;
8
8
  }
9
9
  export declare class SlashCommandEvents {
10
- client: XernerxClient;
10
+ private client;
11
11
  constructor(client: XernerxClient);
12
12
  slashCreate(): void;
13
13
  }
14
14
  export declare class ContextCommandEvents {
15
- client: XernerxClient;
15
+ private client;
16
16
  constructor(client: XernerxClient);
17
17
  contextCreate(): void;
18
18
  }
19
19
  export declare class CommandsDeploy {
20
- client: XernerxClient;
20
+ private client;
21
21
  constructor(client: XernerxClient);
22
22
  deploy(): void;
23
- put(type: string, guild: string, body: Array<object>): void;
23
+ private put;
24
24
  }
@@ -1,9 +1,9 @@
1
1
  import { GatewayVersion, InteractionType, REST, Routes } from 'discord.js';
2
2
  import { InteractionCommandUtil, MessageCommandUtil } from '../utils/CommandUtil.js';
3
3
  import { InteractionArguments, messageArguments } from './CommandArguments.js';
4
- import commandValidation from './CommandValidations.js';
4
+ import commandValidation from '../validators/CommandValidations.js';
5
5
  import { Style } from 'dumfunctions';
6
- import { InhibitorValidation } from './InhibitorValidations.js';
6
+ import { InhibitorValidation } from '../validators/InhibitorValidations.js';
7
7
  export class MessageCommandEvents {
8
8
  client;
9
9
  constructor(client) {
@@ -28,7 +28,9 @@ export class MessageCommandEvents {
28
28
  });
29
29
  }
30
30
  if (this.client.handlerOptions.message?.prefix) {
31
- const prefix = Array.isArray(this.client.handlerOptions.message.prefix) ? this.client.handlerOptions.message.prefix : [this.client.handlerOptions.message.prefix];
31
+ const prefix = Array.isArray(this.client.handlerOptions.message.prefix)
32
+ ? this.client.handlerOptions.message.prefix
33
+ : [this.client.handlerOptions.message.prefix];
32
34
  prefix.map((prefix) => {
33
35
  if (message.content.startsWith(prefix)) {
34
36
  command = message.content.replace(prefix, '').split(/ +/).shift();
@@ -37,13 +39,17 @@ export class MessageCommandEvents {
37
39
  });
38
40
  }
39
41
  if (this.client.handlerOptions.message?.allowMention) {
40
- if (message.mentions.users.has(this.client.user?.id) || message.mentions.repliedUser?.id === this.client.user?.id) {
42
+ if (message.mentions.users.has(this.client.user?.id) ||
43
+ message.mentions.repliedUser?.id === this.client.user?.id) {
41
44
  command = message.content.replace(`<@${this.client.user?.id}>`, '').trim().split(/ +/).shift();
42
45
  px = 'MentionPrefix';
43
46
  }
44
47
  }
45
- const prefix = Array.isArray(this.client.handlerOptions.message?.prefix) ? this.client.handlerOptions.message?.prefix : [this.client.handlerOptions.message?.prefix];
46
- if ((cmd.name.toLowerCase() == command?.toLowerCase() || cmd.aliases?.map((c) => c.toLowerCase())?.includes(command?.toLowerCase())) &&
48
+ const prefix = Array.isArray(this.client.handlerOptions.message?.prefix)
49
+ ? this.client.handlerOptions.message?.prefix
50
+ : [this.client.handlerOptions.message?.prefix];
51
+ if ((cmd.name.toLowerCase() == command?.toLowerCase() ||
52
+ cmd.aliases?.map((c) => c.toLowerCase())?.includes(command?.toLowerCase())) &&
47
53
  (cmd.prefix.includes(px) || prefix?.includes(px) || px === 'MentionPrefix')) {
48
54
  try {
49
55
  if (this.client.handlerOptions.message?.handleTyping)
@@ -53,7 +59,8 @@ export class MessageCommandEvents {
53
59
  return;
54
60
  if (await inhibitor.inhibit())
55
61
  return;
56
- if (cmd.conditions && (await cmd.conditions(message, (await messageArguments(message, cmd)))))
62
+ if (cmd.conditions &&
63
+ (await cmd.conditions(message, (await messageArguments(message, cmd)))))
57
64
  return;
58
65
  await cmd.exec(message, (await messageArguments(message, cmd)));
59
66
  this.client.emit('commandRun', message, cmd);
@@ -87,7 +94,9 @@ export class MessageCommandEvents {
87
94
  });
88
95
  }
89
96
  if (this.client.handlerOptions.message?.prefix) {
90
- const prefix = Array.isArray(this.client.handlerOptions.message.prefix) ? this.client.handlerOptions.message.prefix : [this.client.handlerOptions.message.prefix];
97
+ const prefix = Array.isArray(this.client.handlerOptions.message.prefix)
98
+ ? this.client.handlerOptions.message.prefix
99
+ : [this.client.handlerOptions.message.prefix];
91
100
  prefix.map((prefix) => {
92
101
  if (message?.content?.startsWith(prefix)) {
93
102
  command = message.content.replace(prefix, '').split(/ +/).shift();
@@ -96,13 +105,17 @@ export class MessageCommandEvents {
96
105
  });
97
106
  }
98
107
  if (this.client.handlerOptions.message?.allowMention) {
99
- if (message.mentions.users.has(this.client.user?.id || '') || message.mentions.repliedUser?.id === this.client.user?.id) {
108
+ if (message.mentions.users.has(this.client.user?.id || '') ||
109
+ message.mentions.repliedUser?.id === this.client.user?.id) {
100
110
  command = message?.content?.replace(`<@${this.client.user?.id}>`, '').trim().split(/ +/).shift();
101
111
  px = 'MentionPrefix';
102
112
  }
103
113
  }
104
- const prefix = Array.isArray(this.client.handlerOptions.message?.prefix) ? this.client.handlerOptions.message?.prefix : [this.client.handlerOptions.message?.prefix];
105
- if ((cmd.name.toLowerCase() == command?.toLowerCase() || cmd.aliases?.map((c) => c.toLowerCase())?.includes(command?.toLowerCase())) &&
114
+ const prefix = Array.isArray(this.client.handlerOptions.message?.prefix)
115
+ ? this.client.handlerOptions.message?.prefix
116
+ : [this.client.handlerOptions.message?.prefix];
117
+ if ((cmd.name.toLowerCase() == command?.toLowerCase() ||
118
+ cmd.aliases?.map((c) => c.toLowerCase())?.includes(command?.toLowerCase())) &&
106
119
  (cmd.prefix.includes(px) || prefix?.includes(px) || px === 'MentionPrefix')) {
107
120
  try {
108
121
  if (this.client.handlerOptions.message?.handleTyping)
@@ -113,7 +126,8 @@ export class MessageCommandEvents {
113
126
  return;
114
127
  if (await inhibitor.inhibit())
115
128
  return;
116
- if (cmd.conditions && (await cmd.conditions(message, (await messageArguments(message, cmd)))))
129
+ if (cmd.conditions &&
130
+ (await cmd.conditions(message, (await messageArguments(message, cmd)))))
117
131
  return;
118
132
  await cmd.exec(message, (await messageArguments(message, cmd)));
119
133
  this.client.emit('commandRun', message, cmd);
@@ -128,15 +142,18 @@ export class MessageCommandEvents {
128
142
  }
129
143
  messageDelete() {
130
144
  this.client.on('messageDelete', async (message) => {
131
- if (this.client.cache.messages.has(message.id) && this.client.handlerOptions.message?.handleDeletes) {
132
- if (this.client.handlerOptions.message?.handleTyping)
133
- message.channel.sendTyping();
145
+ if (this.client.cache.messages.has(message.id) &&
146
+ this.client.handlerOptions.message?.handleDeletes) {
134
147
  try {
148
+ if (this.client.handlerOptions.message?.handleTyping)
149
+ message.channel.sendTyping();
135
150
  const msg = this.client.cache.messages.get(message.id);
136
151
  const response = await message.channel.messages.fetch(msg?.response);
137
152
  await response.delete();
138
153
  }
139
- catch { }
154
+ catch (error) {
155
+ this.client.emit('commandError', message, error, null);
156
+ }
140
157
  }
141
158
  });
142
159
  }
@@ -161,12 +178,27 @@ export class SlashCommandEvents {
161
178
  if (commandValidation(interaction, command, this.client))
162
179
  return;
163
180
  if (command.defer?.reply !== false && this.client.handlerOptions.slash?.defer?.reply)
164
- await interaction.deferReply({ ephemeral: this.client.handlerOptions.slash?.defer?.ephemeral, fetchReply: this.client.handlerOptions.slash?.defer?.fetchReply });
181
+ await interaction.deferReply({
182
+ ephemeral: this.client.handlerOptions.slash?.defer?.ephemeral,
183
+ fetchReply: this.client.handlerOptions.slash?.defer?.fetchReply,
184
+ });
165
185
  if (!(interaction.deferred || interaction.replied) && command.defer?.reply)
166
- await interaction.deferReply({ ephemeral: command.defer?.ephemeral, fetchReply: command.defer?.fetchReply });
167
- if (command.conditions && (await command.conditions(interaction, { group: argumentsInfo.group(), subcommand: argumentsInfo.subcommand(), args: await argumentsInfo.arguments() })))
186
+ await interaction.deferReply({
187
+ ephemeral: command.defer?.ephemeral,
188
+ fetchReply: command.defer?.fetchReply,
189
+ });
190
+ if (command.conditions &&
191
+ (await command.conditions(interaction, {
192
+ group: argumentsInfo.group(),
193
+ subcommand: argumentsInfo.subcommand(),
194
+ args: await argumentsInfo.arguments(),
195
+ })))
168
196
  return;
169
- await command.exec(interaction, { group: argumentsInfo.group(), subcommand: argumentsInfo.subcommand(), args: await argumentsInfo.arguments() });
197
+ await command.exec(interaction, {
198
+ group: argumentsInfo.group(),
199
+ subcommand: argumentsInfo.subcommand(),
200
+ args: await argumentsInfo.arguments(),
201
+ });
170
202
  this.client.emit('commandRun', interaction, command);
171
203
  }
172
204
  catch (error) {
@@ -198,9 +230,15 @@ export class ContextCommandEvents {
198
230
  if (command.conditions && (await command.conditions(interaction)))
199
231
  return;
200
232
  if (command.defer?.reply !== false && this.client.handlerOptions.context?.defer?.reply)
201
- await interaction.deferReply({ ephemeral: this.client.handlerOptions.context?.defer?.ephemeral, fetchReply: this.client.handlerOptions.context?.defer?.fetchReply });
233
+ await interaction.deferReply({
234
+ ephemeral: this.client.handlerOptions.context?.defer?.ephemeral,
235
+ fetchReply: this.client.handlerOptions.context?.defer?.fetchReply,
236
+ });
202
237
  if (!(interaction.deferred || interaction.replied) && command.defer?.reply)
203
- await interaction.deferReply({ ephemeral: command.defer?.ephemeral, fetchReply: command.defer?.fetchReply });
238
+ await interaction.deferReply({
239
+ ephemeral: command.defer?.ephemeral,
240
+ fetchReply: command.defer?.fetchReply,
241
+ });
204
242
  await command.exec(interaction);
205
243
  this.client.emit('commandRun', interaction, command);
206
244
  }
@@ -220,30 +258,39 @@ export class CommandsDeploy {
220
258
  deploy() {
221
259
  this.client.once('ready', async (client) => {
222
260
  const slashCommands = [], contextCommands = [];
223
- this.client.commands.context.map((command) => (command.data ? contextCommands.push(command.data.toJSON()) : null));
261
+ this.client.commands.context.map((command) => command.data ? contextCommands.push(command.data.toJSON()) : null);
224
262
  this.client.commands.slash.map((command) => (command.data ? slashCommands.push(command.data.toJSON()) : null));
225
263
  try {
226
- const global = { slash: this.client.handlerOptions.slash?.global, context: this.client.handlerOptions.context?.global };
227
- const guild = { slash: this.client.handlerOptions.slash?.guildId, context: this.client.handlerOptions.context?.guildId };
264
+ const global = {
265
+ slash: this.client.handlerOptions.slash?.global,
266
+ context: this.client.handlerOptions.context?.global,
267
+ };
268
+ const guild = {
269
+ slash: this.client.handlerOptions.slash?.guildId,
270
+ context: this.client.handlerOptions.context?.guildId,
271
+ };
228
272
  if (global.slash && global.context) {
229
273
  if (guild.slash !== guild.context)
230
274
  console.info(Style.log(`Xernerx | Warning: slash and context commands are both set to global, but don't have a matching guildId, using ${(await this.client.guilds.fetch(this.client.handlerOptions.slash?.guildId)).name}!`, { color: Style.TextColor.Red }));
231
275
  this.put('global', guild.slash, [...contextCommands, ...slashCommands]);
232
276
  this.put('guild', guild.slash, []);
233
277
  }
234
- if (global.slash && !global.context) {
278
+ if (global.slash && global.context === false) {
235
279
  this.put('global', guild.slash, slashCommands);
236
280
  }
237
- if (!global.slash && global.context) {
281
+ if (global.slash === false && global.context) {
238
282
  this.put('global', guild.context, contextCommands);
239
283
  }
240
- if (!global.slash && !global.context) {
284
+ if (global.slash === false && global.context === false) {
241
285
  this.put('guild', guild.slash, [...contextCommands, ...slashCommands]);
242
286
  }
243
- console.log(Style.log(`Xernerx | Deployed ${slashCommands.length} slash commands ${global.slash ? 'globally' : 'locally'} and ${contextCommands.length} context commands ${global.context ? 'globally' : 'locally'}.`, { color: Style.TextColor.Purple }));
287
+ if (this.client.handlerOptions.context?.logging || this.client.handlerOptions.slash?.logging)
288
+ console.info(Style.log(`Xernerx | Deployed ${slashCommands.length} slash commands ${global.slash ? 'globally' : 'locally'} and ${contextCommands.length} context commands ${global.context ? 'globally' : 'locally'}.`, { color: Style.TextColor.Purple }));
244
289
  }
245
290
  catch (error) {
246
- console.error(Style.log(`Xernerx | Couldn't deploy interaction commands because <${error}>.`, { color: Style.BackgroundColor.Red }));
291
+ console.error(Style.log(`Xernerx | Couldn't deploy interaction commands because <${error}>.`, {
292
+ color: Style.BackgroundColor.Red,
293
+ }));
247
294
  }
248
295
  });
249
296
  }
@@ -1,6 +1,7 @@
1
- import { ExtensionBuilder, XernerxClient } from "../main.js";
1
+ import XernerxExtensionBuilder from 'xernerx-extension-builder';
2
+ import XernerxClient from '../client/XernerxClient.js';
2
3
  export default class Extensions {
3
- client: XernerxClient;
4
+ private client;
4
5
  constructor(client: XernerxClient);
5
- load(extensions: Array<ExtensionBuilder>, logging?: boolean): Promise<void>;
6
+ load(extensions: Array<XernerxExtensionBuilder>, logging?: boolean): Promise<void>;
6
7
  }
@@ -1,4 +1,4 @@
1
- import { Style } from "dumfunctions";
1
+ import { Style } from 'dumfunctions';
2
2
  export default class Extensions {
3
3
  client;
4
4
  constructor(client) {
@@ -6,13 +6,15 @@ export default class Extensions {
6
6
  }
7
7
  async load(extensions, logging = false) {
8
8
  const exts = [];
9
- extensions.map(extension => {
9
+ extensions.map((extension) => {
10
10
  try {
11
11
  this.client.extensions[extension.name] = extension;
12
12
  exts.push(extension.name);
13
13
  }
14
14
  catch (error) {
15
- console.error(Style.log(`Xernerx | An error occurred trying to load ${extension.name}, error: <${error}>`, { color: Style.BackgroundColor.Red }));
15
+ console.error(Style.log(`Xernerx | An error occurred trying to load ${extension.name}, error: <${error}>`, {
16
+ color: Style.BackgroundColor.Red,
17
+ }));
16
18
  }
17
19
  });
18
20
  if (logging)
@@ -0,0 +1,38 @@
1
+ declare const _default: {
2
+ name: string;
3
+ version: string;
4
+ type: string;
5
+ description: string;
6
+ main: string;
7
+ keywords: string[];
8
+ author: string;
9
+ license: string;
10
+ homepage: string;
11
+ packageManager: string;
12
+ scripts: {
13
+ start: string;
14
+ patch: string;
15
+ minor: string;
16
+ major: string;
17
+ site: string;
18
+ commit: string;
19
+ package: string;
20
+ };
21
+ repository: {
22
+ type: string;
23
+ url: string;
24
+ };
25
+ bugs: {
26
+ url: string;
27
+ };
28
+ dependencies: {
29
+ '@sapphire/shapeshift': string;
30
+ 'discord.js': string;
31
+ dumfunctions: string;
32
+ 'xernerx-extension-builder': string;
33
+ };
34
+ devDependencies: {
35
+ typescript: string;
36
+ };
37
+ };
38
+ export default _default;
@@ -0,0 +1,37 @@
1
+ export default {
2
+ name: 'xernerx',
3
+ version: '3.3.7',
4
+ type: 'module',
5
+ description: 'A bot framework for discord.js.',
6
+ main: 'dist/main.js',
7
+ keywords: ['discord.js', 'discord', 'framework'],
8
+ author: 'Dummi',
9
+ license: 'MIT',
10
+ homepage: 'https://xernerx.github.io/xernerx/home.html',
11
+ packageManager: 'npm@8.5.5',
12
+ scripts: {
13
+ start: 'npm i && npm fund && npm audit fix --force && npm link && npm run package && tsc -w',
14
+ patch: 'git add . && npm run commit && npm version patch && npm publish && git push',
15
+ minor: 'git add . && npm run commit && npm version minor && npm publish && git push',
16
+ major: 'git add . && npm run commit && npm version major && npm publish && git push',
17
+ site: 'git add docs && npm run commit && git push',
18
+ commit: 'node ../.scripts/commit.js',
19
+ package: 'node ../.scripts/rewritePackage.js',
20
+ },
21
+ repository: {
22
+ type: 'git',
23
+ url: 'git+https://github.com/xernerx/xernerx.git',
24
+ },
25
+ bugs: {
26
+ url: 'https://github.com/xernerx/xernerx/issues',
27
+ },
28
+ dependencies: {
29
+ '@sapphire/shapeshift': '^3.8.1',
30
+ 'discord.js': '^14.7.0',
31
+ dumfunctions: '^2.0.0',
32
+ 'xernerx-extension-builder': '^0.0.2',
33
+ },
34
+ devDependencies: {
35
+ typescript: '^4.9.4',
36
+ },
37
+ };
@@ -10,7 +10,7 @@ export var InhibitorType;
10
10
  InhibitorType["Message"] = "Message";
11
11
  InhibitorType["Interaction"] = "Interaction";
12
12
  InhibitorType["Channel"] = "Channel";
13
- })(InhibitorType = InhibitorType || (InhibitorType = {}));
13
+ })(InhibitorType || (InhibitorType = {}));
14
14
  export var CommandType;
15
15
  (function (CommandType) {
16
16
  CommandType["Message"] = "MessageCommand";
@@ -21,15 +21,15 @@ export var CommandType;
21
21
  CommandType["MessageCommand"] = "MessageCommand";
22
22
  CommandType["SlashCommand"] = "SlashCommand";
23
23
  CommandType["ContextCommand"] = "ContextCommand";
24
- })(CommandType = CommandType || (CommandType = {}));
24
+ })(CommandType || (CommandType = {}));
25
25
  export var ContextCommandType;
26
26
  (function (ContextCommandType) {
27
27
  ContextCommandType[ContextCommandType["Message"] = 3] = "Message";
28
28
  ContextCommandType[ContextCommandType["User"] = 2] = "User";
29
- })(ContextCommandType = ContextCommandType || (ContextCommandType = {}));
29
+ })(ContextCommandType || (ContextCommandType = {}));
30
30
  export var EventEmitterType;
31
31
  (function (EventEmitterType) {
32
32
  EventEmitterType["Client"] = "client";
33
33
  EventEmitterType["Rest"] = "rest";
34
34
  EventEmitterType["Process"] = "process";
35
- })(EventEmitterType = EventEmitterType || (EventEmitterType = {}));
35
+ })(EventEmitterType || (EventEmitterType = {}));
@@ -1,5 +1,6 @@
1
1
  import { CacheFactory, ChannelType, ContextMenuCommandType, MessageMentionOptions, Partials, PresenceData, RESTOptions, SweeperOptions, WebSocketOptions } from 'discord.js';
2
- import { ContextCommandType, EventEmitterType, ExtensionBuilder, InhibitorType } from '../main.js';
2
+ import XernerxExtensionBuilder from 'xernerx-extension-builder';
3
+ import { ContextCommandType, EventEmitterType, InhibitorType } from './enums.js';
3
4
  import { MessageCommandArgsTypes } from './types.js';
4
5
  export interface DiscordOptions {
5
6
  shards?: number | number[] | 'auto';
@@ -36,7 +37,7 @@ export interface HandlerOptions {
36
37
  inhibitors?: InhibitorHandlerOptions;
37
38
  }
38
39
  export interface ExtensionOptions {
39
- extensions: Array<ExtensionBuilder>;
40
+ extensions: Array<XernerxExtensionBuilder>;
40
41
  logging?: boolean;
41
42
  }
42
43
  export interface MessageCommandOptions {
File without changes
@@ -8,7 +8,7 @@ interface Presence {
8
8
  interval?: number;
9
9
  }
10
10
  export declare class ClientUtil {
11
- client: XernerxClient;
11
+ private client;
12
12
  constructor(client: XernerxClient);
13
13
  uptime(timestamp: number | null): string;
14
14
  getSubcommands(name: string): object[];
@@ -3,17 +3,6 @@ export class ClientUtil {
3
3
  client;
4
4
  constructor(client) {
5
5
  this.client = client;
6
- this.uptime = this.uptime;
7
- this.getSubcommands = this.getSubcommands;
8
- this.isOwner = this.isOwner;
9
- this.getAllCommands = this.getAllCommands;
10
- this.getAllMessageCommands = this.getAllMessageCommands;
11
- this.getAllSlashCommands = this.getAllSlashCommands;
12
- this.getAllContextCommands = this.getAllContextCommands;
13
- this.setPresence = this.setPresence;
14
- this.getCooldowns = this.getCooldowns;
15
- this.getCooldownTimers = this.getCooldownTimers;
16
- this.defer = this.defer;
17
6
  }
18
7
  uptime(timestamp) {
19
8
  if (!timestamp)
@@ -25,26 +25,32 @@ interface ButtonOptions {
25
25
  ephemeral?: boolean;
26
26
  }
27
27
  export declare class MessageCommandUtil {
28
- #private;
29
- client: XernerxClient;
30
- message: XernerxMessage;
28
+ private client;
29
+ private message;
31
30
  constructor(client: XernerxClient, message: Message & XernerxMessage);
32
31
  reply(content: MessagePayload | string): Promise<Message<boolean> | undefined>;
33
32
  send(content: MessagePayload | string): Promise<Message<true> | Message<false> | undefined>;
34
33
  defer(time: number): Promise<unknown>;
35
34
  getCommands(): import("@discordjs/collection").Collection<string, import("../main.js").MessageCommandBuilder>;
35
+ getCommandName(): void;
36
+ selectMenuPaginator(embeds: Array<EmbedBuilder>, options?: SelectMenuOptions): void;
37
+ buttonPaginator(embeds: Array<EmbedBuilder>, options: ButtonOptions): void;
38
+ buttonMenuPaginator(embeds: Array<EmbedBuilder>, options: ButtonOptions & SelectMenuOptions): void;
36
39
  isOwner(): boolean;
40
+ createModal(): void;
37
41
  }
38
42
  export declare class InteractionCommandUtil {
39
- #private;
40
- client: XernerxClient;
41
- interaction: any;
43
+ private client;
44
+ private interaction;
42
45
  constructor(client: XernerxClient, interaction: Interaction);
43
46
  reply(content: MessagePayload | string): any;
44
47
  defer(time: number): Promise<unknown>;
45
48
  getCommands(): import("@discordjs/collection").Collection<string, import("../main.js").SlashCommandBuilder> | import("@discordjs/collection").Collection<string, import("../main.js").ContextCommandBuilder>;
49
+ getCommandName(): void;
46
50
  selectMenuPaginator(embeds: Array<EmbedBuilder>, options?: SelectMenuOptions): void;
47
51
  buttonPaginator(embeds: Array<EmbedBuilder>, options: ButtonOptions): void;
52
+ buttonMenuPaginator(embeds: Array<EmbedBuilder>, options: ButtonOptions & SelectMenuOptions): void;
48
53
  isOwner(): boolean;
54
+ createModal(): void;
49
55
  }
50
56
  export {};