xernerx 3.5.1 → 3.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 (121) hide show
  1. package/dist/{build → cjs/build}/ContextCommandBuilder.d.ts +31 -28
  2. package/dist/cjs/build/ContextCommandBuilder.js +97 -0
  3. package/dist/cjs/build/EventBuilder.js +44 -0
  4. package/dist/{build → cjs/build}/InhibitorBuilder.d.ts +1 -1
  5. package/dist/cjs/build/InhibitorBuilder.js +37 -0
  6. package/dist/{build → cjs/build}/MessageCommandBuilder.d.ts +23 -17
  7. package/dist/cjs/build/MessageCommandBuilder.js +100 -0
  8. package/dist/{build → cjs/build}/SlashCommandBuilder.d.ts +25 -18
  9. package/dist/cjs/build/SlashCommandBuilder.js +169 -0
  10. package/dist/{client → cjs/client}/XernerxClient.d.ts +1 -0
  11. package/dist/cjs/client/XernerxClient.js +120 -0
  12. package/dist/{handlers → cjs/handlers}/CommandHandler.js +11 -8
  13. package/dist/{handlers → cjs/handlers}/EventHandler.js +6 -3
  14. package/dist/cjs/handlers/Handler.js +308 -0
  15. package/dist/{handlers → cjs/handlers}/InhibitorHandler.js +6 -3
  16. package/dist/cjs/handlers/WebhookHandler.d.ts +7 -0
  17. package/dist/cjs/handlers/WebhookHandler.js +23 -0
  18. package/dist/{main.d.ts → cjs/main.d.ts} +15 -1
  19. package/dist/cjs/main.js +112 -0
  20. package/dist/{models → cjs/models}/CommandArguments.d.ts +1 -1
  21. package/dist/{models → cjs/models}/CommandArguments.js +37 -52
  22. package/dist/cjs/models/Events.js +309 -0
  23. package/dist/cjs/models/Extensions.js +26 -0
  24. package/dist/cjs/models/XernerxUser.d.ts +2 -0
  25. package/dist/cjs/models/XernerxUser.js +12 -0
  26. package/dist/{tools → cjs/tools}/XernerxError.js +4 -1
  27. package/dist/{tools → cjs/tools}/package.d.ts +4 -9
  28. package/dist/{tools → cjs/tools}/package.js +14 -17
  29. package/dist/cjs/types/enums.d.ts +44 -0
  30. package/dist/cjs/types/enums.js +38 -0
  31. package/dist/{types → cjs/types}/interfaces.d.ts +2 -0
  32. package/dist/cjs/types/interfaces.js +2 -0
  33. package/dist/{types → cjs/types}/options.d.ts +13 -0
  34. package/dist/cjs/types/options.js +2 -0
  35. package/dist/{types → cjs/types}/types.d.ts +38 -10
  36. package/dist/cjs/types/types.js +2 -0
  37. package/dist/{utils → cjs/utils}/ClientUtil.d.ts +1 -0
  38. package/dist/{utils → cjs/utils}/ClientUtil.js +73 -84
  39. package/dist/{utils → cjs/utils}/CommandUtil.d.ts +4 -2
  40. package/dist/{utils → cjs/utils}/CommandUtil.js +102 -103
  41. package/dist/{validators → cjs/validators}/CommandValidations.d.ts +6 -1
  42. package/dist/{validators → cjs/validators}/CommandValidations.js +36 -50
  43. package/dist/{validators → cjs/validators}/InhibitorValidations.js +12 -14
  44. package/dist/mjs/build/ContextCommandBuilder.d.ts +63 -0
  45. package/dist/mjs/build/ContextCommandBuilder.js +97 -0
  46. package/dist/mjs/build/EventBuilder.d.ts +21 -0
  47. package/dist/mjs/build/EventBuilder.js +44 -0
  48. package/dist/mjs/build/InhibitorBuilder.d.ts +19 -0
  49. package/dist/mjs/build/InhibitorBuilder.js +37 -0
  50. package/dist/mjs/build/MessageCommandBuilder.d.ts +59 -0
  51. package/dist/mjs/build/MessageCommandBuilder.js +100 -0
  52. package/dist/mjs/build/SlashCommandBuilder.d.ts +65 -0
  53. package/dist/mjs/build/SlashCommandBuilder.js +169 -0
  54. package/dist/mjs/client/XernerxClient.d.ts +29 -0
  55. package/dist/mjs/client/XernerxClient.js +120 -0
  56. package/dist/mjs/handlers/CommandHandler.d.ts +27 -0
  57. package/dist/mjs/handlers/CommandHandler.js +45 -0
  58. package/dist/mjs/handlers/EventHandler.d.ts +13 -0
  59. package/dist/mjs/handlers/EventHandler.js +19 -0
  60. package/dist/mjs/handlers/Handler.d.ts +57 -0
  61. package/dist/mjs/handlers/Handler.js +308 -0
  62. package/dist/mjs/handlers/InhibitorHandler.d.ts +18 -0
  63. package/dist/mjs/handlers/InhibitorHandler.js +24 -0
  64. package/dist/mjs/handlers/WebhookHandler.d.ts +7 -0
  65. package/dist/mjs/handlers/WebhookHandler.js +23 -0
  66. package/dist/{main.js → mjs/main.d.ts} +20 -18
  67. package/dist/mjs/main.js +112 -0
  68. package/dist/mjs/models/CommandArguments.d.ts +17 -0
  69. package/dist/mjs/models/CommandArguments.js +106 -0
  70. package/dist/mjs/models/Events.d.ts +24 -0
  71. package/dist/mjs/models/Events.js +309 -0
  72. package/dist/mjs/models/Extensions.d.ts +7 -0
  73. package/dist/mjs/models/Extensions.js +26 -0
  74. package/dist/mjs/models/XernerxUser.d.ts +2 -0
  75. package/dist/mjs/models/XernerxUser.js +12 -0
  76. package/dist/mjs/tools/XernerxError.d.ts +5 -0
  77. package/dist/mjs/tools/XernerxError.js +11 -0
  78. package/dist/mjs/tools/package.d.ts +44 -0
  79. package/dist/mjs/tools/package.js +45 -0
  80. package/dist/mjs/types/enums.d.ts +44 -0
  81. package/dist/mjs/types/enums.js +38 -0
  82. package/dist/mjs/types/interfaces.d.ts +27 -0
  83. package/dist/mjs/types/interfaces.js +2 -0
  84. package/dist/mjs/types/options.d.ts +254 -0
  85. package/dist/mjs/types/options.js +2 -0
  86. package/dist/mjs/types/types.d.ts +62 -0
  87. package/dist/mjs/types/types.js +2 -0
  88. package/dist/mjs/utils/ClientUtil.d.ts +26 -0
  89. package/dist/mjs/utils/ClientUtil.js +211 -0
  90. package/dist/mjs/utils/CommandUtil.d.ts +58 -0
  91. package/dist/mjs/utils/CommandUtil.js +247 -0
  92. package/dist/mjs/validators/CommandValidations.d.ts +12 -0
  93. package/dist/mjs/validators/CommandValidations.js +169 -0
  94. package/dist/mjs/validators/InhibitorValidations.d.ts +11 -0
  95. package/dist/mjs/validators/InhibitorValidations.js +40 -0
  96. package/package.json +11 -15
  97. package/dist/build/ContextCommandBuilder.js +0 -93
  98. package/dist/build/EventBuilder.js +0 -34
  99. package/dist/build/InhibitorBuilder.js +0 -27
  100. package/dist/build/MessageCommandBuilder.js +0 -90
  101. package/dist/build/SlashCommandBuilder.js +0 -125
  102. package/dist/client/XernerxClient.js +0 -101
  103. package/dist/handlers/Handler.js +0 -250
  104. package/dist/main.cjs +0 -2023
  105. package/dist/models/Events.js +0 -294
  106. package/dist/models/Extensions.js +0 -23
  107. package/dist/types/enums.d.ts +0 -35
  108. package/dist/types/enums.js +0 -35
  109. package/dist/types/interfaces.js +0 -1
  110. package/dist/types/options.js +0 -1
  111. package/dist/types/types.js +0 -1
  112. package/dist/validators/Shapes.js +0 -1
  113. /package/dist/{build → cjs/build}/EventBuilder.d.ts +0 -0
  114. /package/dist/{handlers → cjs/handlers}/CommandHandler.d.ts +0 -0
  115. /package/dist/{handlers → cjs/handlers}/EventHandler.d.ts +0 -0
  116. /package/dist/{handlers → cjs/handlers}/Handler.d.ts +0 -0
  117. /package/dist/{handlers → cjs/handlers}/InhibitorHandler.d.ts +0 -0
  118. /package/dist/{models → cjs/models}/Events.d.ts +0 -0
  119. /package/dist/{models → cjs/models}/Extensions.d.ts +0 -0
  120. /package/dist/{tools → cjs/tools}/XernerxError.d.ts +0 -0
  121. /package/dist/{validators → cjs/validators}/InhibitorValidations.d.ts +0 -0
@@ -1,6 +1,14 @@
1
- import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder, StringSelectMenuBuilder } from 'discord.js';
2
- import XernerxError from '../tools/XernerxError.js';
3
- export class MessageCommandUtil {
1
+ 'use strict';
2
+ var __importDefault =
3
+ (this && this.__importDefault) ||
4
+ function (mod) {
5
+ return mod && mod.__esModule ? mod : { default: mod };
6
+ };
7
+ Object.defineProperty(exports, '__esModule', { value: true });
8
+ exports.InteractionCommandUtil = exports.MessageCommandUtil = void 0;
9
+ const discord_js_1 = require('discord.js');
10
+ const XernerxError_js_1 = __importDefault(require('../tools/XernerxError.js'));
11
+ class MessageCommandUtil {
4
12
  client;
5
13
  message;
6
14
  constructor(client, message) {
@@ -8,8 +16,7 @@ export class MessageCommandUtil {
8
16
  this.message = message;
9
17
  }
10
18
  async reply(content) {
11
- if (this.client.cache.messages.has(this.message.id))
12
- var existingMessage = this.client.cache.messages.get(this.message.id);
19
+ if (this.client.cache.messages.has(this.message.id)) var existingMessage = this.client.cache.messages.get(this.message.id);
13
20
  if (!existingMessage) {
14
21
  const msg = await this.message.reply(content);
15
22
  this.message.response = msg.id;
@@ -26,8 +33,7 @@ export class MessageCommandUtil {
26
33
  const msg = await this.message.channel.messages.fetch(existingMessage.response);
27
34
  msg.edit(content);
28
35
  return msg;
29
- }
30
- catch {
36
+ } catch {
31
37
  const msg = await this.message.reply(content);
32
38
  this.message.response = msg.id;
33
39
  if (this.client.handlerOptions.message?.handleEdits || this.client.handlerOptions.message?.handleDeletes) {
@@ -40,8 +46,7 @@ export class MessageCommandUtil {
40
46
  }
41
47
  }
42
48
  async send(content) {
43
- if (this.client.cache.messages.has(this.message.id))
44
- var existingMessage = this.client.cache.messages.get(this.message.id);
49
+ if (this.client.cache.messages.has(this.message.id)) var existingMessage = this.client.cache.messages.get(this.message.id);
45
50
  if (!existingMessage) {
46
51
  const msg = await this.message.channel.send(content);
47
52
  this.message.response = msg.id;
@@ -58,8 +63,7 @@ export class MessageCommandUtil {
58
63
  const msg = await this.message.channel.messages.fetch(existingMessage.response);
59
64
  msg.edit(content);
60
65
  return msg;
61
- }
62
- catch {
66
+ } catch {
63
67
  const msg = await this.message.channel.send(content);
64
68
  this.message.response = msg.id;
65
69
  if (this.client.handlerOptions.message?.handleEdits || this.client.handlerOptions.message?.handleDeletes) {
@@ -77,16 +81,17 @@ export class MessageCommandUtil {
77
81
  getCommands() {
78
82
  return this.client.commands.message;
79
83
  }
80
- getCommandName() { }
81
- selectMenuPaginator(embeds, options) { }
82
- buttonPaginator(embeds, options) { }
83
- buttonMenuPaginator(embeds, options) { }
84
+ getCommandName() {}
85
+ selectMenuPaginator(embeds, options) {}
86
+ buttonPaginator(embeds, options) {}
87
+ buttonMenuPaginator(embeds, options) {}
84
88
  isOwner() {
85
89
  return this.client.util.isOwner(this.message.author.id);
86
90
  }
87
- createModal() { }
91
+ createModal() {}
88
92
  }
89
- export class InteractionCommandUtil {
93
+ exports.MessageCommandUtil = MessageCommandUtil;
94
+ class InteractionCommandUtil {
90
95
  client;
91
96
  interaction;
92
97
  constructor(client, interaction) {
@@ -100,23 +105,17 @@ export class InteractionCommandUtil {
100
105
  return new Promise((resolve) => setTimeout(resolve, time));
101
106
  }
102
107
  getCommands() {
103
- if (this.interaction.commandType === 1)
104
- return this.client.commands.slash;
105
- else
106
- return this.client.commands.context;
108
+ if (this.interaction.commandType === 1) return this.client.commands.slash;
109
+ else return this.client.commands.context;
107
110
  }
108
- getCommandName() { }
111
+ getCommandName() {}
109
112
  selectMenuPaginator(embeds, options) {
110
- if (!Array.isArray(embeds))
111
- throw new XernerxError(`Expected embeds to be of type array, received ${typeof embeds} instead.`);
112
- if (embeds.length > 25)
113
- throw new XernerxError(`Max select menu length is 25.`);
114
- if (typeof options !== 'object')
115
- options = {};
116
- if (!Array.isArray(options.components))
117
- options.components = [];
113
+ if (!Array.isArray(embeds)) throw new XernerxError_js_1.default(`Expected embeds to be of type array, received ${typeof embeds} instead.`);
114
+ if (embeds.length > 25) throw new XernerxError_js_1.default(`Max select menu length is 25.`);
115
+ if (typeof options !== 'object') options = {};
116
+ if (!Array.isArray(options.components)) options.components = [];
118
117
  if (!options.index) {
119
- options.index = new EmbedBuilder().setTitle('Index').setColor('Random');
118
+ options.index = new discord_js_1.EmbedBuilder().setTitle('Index').setColor('Random');
120
119
  for (const embed of embeds) {
121
120
  options.index.addFields([
122
121
  {
@@ -128,10 +127,14 @@ export class InteractionCommandUtil {
128
127
  }
129
128
  }
130
129
  if (!options.row) {
131
- options.row = new ActionRowBuilder();
132
- if (!options.id)
133
- options.id = `${this.interaction.id}-menu`;
134
- options.component = new StringSelectMenuBuilder().setCustomId(options.id).setMaxValues(1).setMinValues(1).setPlaceholder('Select a page.').addOptions({ label: 'index', value: '0' });
130
+ options.row = new discord_js_1.ActionRowBuilder();
131
+ if (!options.id) options.id = `${this.interaction.id}-menu`;
132
+ options.component = new discord_js_1.StringSelectMenuBuilder()
133
+ .setCustomId(options.id)
134
+ .setMaxValues(1)
135
+ .setMinValues(1)
136
+ .setPlaceholder('Select a page.')
137
+ .addOptions({ label: 'index', value: '0' });
135
138
  embeds.map((embed, i = 0) => {
136
139
  options?.component?.addOptions({
137
140
  label: embed.data.title || 'No Name',
@@ -150,42 +153,37 @@ export class InteractionCommandUtil {
150
153
  (options.reply === undefined || options.reply === true ? this.interaction.util.reply(content) : this.interaction.channel.send(content)).then(() => {
151
154
  const collector = this.interaction.channel
152
155
  .createMessageComponentCollector({
153
- filter: options?.filter,
154
- time: options?.time || 60000,
155
- })
156
+ filter: options?.filter,
157
+ time: options?.time || 60000,
158
+ })
156
159
  .on('collect', (interaction) => {
157
- if (!interaction.customId.startsWith(this.interaction.id))
158
- return;
159
- interaction.update({
160
- embeds: [embeds[parseInt(interaction.values[0])]],
161
- });
162
- })
160
+ if (!interaction.customId.startsWith(this.interaction.id)) return;
161
+ interaction.update({
162
+ embeds: [embeds[parseInt(interaction.values[0])]],
163
+ });
164
+ })
163
165
  .on('end', () => {
164
- this.interaction.editReply({ components: [] });
165
- });
166
+ this.interaction.editReply({ components: [] });
167
+ });
166
168
  });
167
169
  }
168
170
  buttonPaginator(embeds, options) {
169
- if (!Array.isArray(embeds))
170
- throw new XernerxError(`Expected embeds to be of type array, received ${typeof embeds} instead.`);
171
- if (embeds.length <= 0)
172
- throw new XernerxError(`The minimum embeds is 1.`);
173
- if (typeof options !== 'object')
174
- options = {};
175
- if (!Array.isArray(options.components))
176
- options.components = [];
171
+ if (!Array.isArray(embeds)) throw new XernerxError_js_1.default(`Expected embeds to be of type array, received ${typeof embeds} instead.`);
172
+ if (embeds.length <= 0) throw new XernerxError_js_1.default(`The minimum embeds is 1.`);
173
+ if (typeof options !== 'object') options = {};
174
+ if (!Array.isArray(options.components)) options.components = [];
177
175
  if (!options.row) {
178
- options.row = new ActionRowBuilder();
179
- if (!options.id)
180
- options.id = `${this.interaction.id}-menu`;
176
+ options.row = new discord_js_1.ActionRowBuilder();
177
+ if (!options.id) options.id = `${this.interaction.id}-menu`;
181
178
  }
182
- if (!options.buttons)
183
- options.buttons = ['⏮️', '◀️', '⏹️', '▶️', '⏭️'];
179
+ if (!options.buttons) options.buttons = ['⏮️', '◀️', '⏹️', '▶️', '⏭️'];
184
180
  for (const button of options.buttons) {
185
- options.row.addComponents(new ButtonBuilder()
186
- .setCustomId(`${this.interaction.id}-${options.buttons.indexOf(button)}`)
187
- .setEmoji(button)
188
- .setStyle(ButtonStyle.Primary));
181
+ options.row.addComponents(
182
+ new discord_js_1.ButtonBuilder()
183
+ .setCustomId(`${this.interaction.id}-${options.buttons.indexOf(button)}`)
184
+ .setEmoji(button)
185
+ .setStyle(discord_js_1.ButtonStyle.Primary)
186
+ );
189
187
  }
190
188
  let embed = embeds[options.index || 0];
191
189
  const content = {
@@ -196,53 +194,54 @@ export class InteractionCommandUtil {
196
194
  (options.reply === undefined || options.reply === true ? this.interaction.util.reply(content) : this.interaction.channel.send(content)).then((message) => {
197
195
  const collector = message.channel
198
196
  .createMessageComponentCollector({
199
- filter: options.filter,
200
- time: options?.time || 60000,
201
- })
197
+ filter: options.filter,
198
+ time: options?.time || 60000,
199
+ })
202
200
  .on('collect', (interaction) => {
203
- let stop = false;
204
- if (interaction.customId.startsWith(this.interaction.id)) {
205
- switch (Number(interaction.customId.split(/-/).pop())) {
206
- case 0: {
207
- embed = embeds[0];
208
- break;
209
- }
210
- case 1: {
211
- embed = embeds[embeds.indexOf(embed) >= 1 ? embeds.indexOf(embed) - 1 : 0];
212
- break;
213
- }
214
- case 2: {
215
- collector.stop();
216
- stop = true;
217
- break;
218
- }
219
- case 3: {
220
- embed = embeds[embeds.indexOf(embed) < embeds.length - 1 ? embeds.indexOf(embed) + 1 : embeds.length - 1];
221
- break;
222
- }
223
- case 4: {
224
- embed = embeds[embeds.length - 1];
225
- break;
201
+ let stop = false;
202
+ if (interaction.customId.startsWith(this.interaction.id)) {
203
+ switch (Number(interaction.customId.split(/-/).pop())) {
204
+ case 0: {
205
+ embed = embeds[0];
206
+ break;
207
+ }
208
+ case 1: {
209
+ embed = embeds[embeds.indexOf(embed) >= 1 ? embeds.indexOf(embed) - 1 : 0];
210
+ break;
211
+ }
212
+ case 2: {
213
+ collector.stop();
214
+ stop = true;
215
+ break;
216
+ }
217
+ case 3: {
218
+ embed = embeds[embeds.indexOf(embed) < embeds.length - 1 ? embeds.indexOf(embed) + 1 : embeds.length - 1];
219
+ break;
220
+ }
221
+ case 4: {
222
+ embed = embeds[embeds.length - 1];
223
+ break;
224
+ }
226
225
  }
226
+ stop
227
+ ? interaction.update({
228
+ embeds: [embed],
229
+ components: [],
230
+ })
231
+ : interaction.update({
232
+ embeds: [embed],
233
+ });
227
234
  }
228
- stop
229
- ? interaction.update({
230
- embeds: [embed],
231
- components: [],
232
- })
233
- : interaction.update({
234
- embeds: [embed],
235
- });
236
- }
237
- })
235
+ })
238
236
  .on('end', () => {
239
- this.interaction.editReply({ components: [] });
240
- });
237
+ this.interaction.editReply({ components: [] });
238
+ });
241
239
  });
242
240
  }
243
- buttonMenuPaginator(embeds, options) { }
241
+ buttonMenuPaginator(embeds, options) {}
244
242
  isOwner() {
245
243
  return this.client.util.isOwner(this.interaction.user.id);
246
244
  }
247
- createModal() { }
245
+ createModal() {}
248
246
  }
247
+ exports.InteractionCommandUtil = InteractionCommandUtil;
@@ -4,4 +4,9 @@ import MessageCommandBuilder from '../build/MessageCommandBuilder.js';
4
4
  import SlashCommandBuilder from '../build/SlashCommandBuilder.js';
5
5
  import XernerxClient from '../client/XernerxClient.js';
6
6
  import { XernerxMessage } from '../types/types.js';
7
- export default function commandValidation(action: XernerxMessage | Interaction, command: SlashCommandBuilder | MessageCommandBuilder | ContextCommandBuilder | any, client: XernerxClient, res?: boolean): boolean;
7
+ export default function commandValidation(
8
+ action: XernerxMessage | Interaction,
9
+ command: SlashCommandBuilder | MessageCommandBuilder | ContextCommandBuilder | any,
10
+ client: XernerxClient,
11
+ res?: boolean
12
+ ): boolean;
@@ -1,43 +1,36 @@
1
- import { Message } from 'discord.js';
2
- import { CommandType } from '../types/enums.js';
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
+ const discord_js_1 = require('discord.js');
4
+ const enums_js_1 = require('../types/enums.js');
3
5
  function getUser(from) {
4
- if (from instanceof Message)
5
- return from.author;
6
- else
7
- return from.user;
6
+ if (from instanceof discord_js_1.Message) return from.author;
7
+ else return from.user;
8
8
  }
9
- export default function commandValidation(action, command, client, res = false) {
9
+ function commandValidation(action, command, client, res = false) {
10
10
  let user = getUser(action);
11
- if ((command.ignoreOwner || client.settings.ignore?.owner) && client.util.isOwner(user.id))
12
- return res;
13
- else if (inCooldown(user, client, command, action))
14
- return true;
11
+ if (client.settings.ignore?.owner && client.util.isOwner(user.id)) return res;
12
+ else if (inCooldown(user, client, command, action)) return true;
15
13
  else if (command.owner && !client.util.isOwner(user.id)) {
16
14
  res = true;
17
15
  emit(client, action, command, 'Not an owner', client.settings.ownerId);
18
- }
19
- else if (command.channelType?.length > 0 || command.channelType) {
20
- if (!Array.isArray(command.channelType))
21
- command.channelType = [command.channelType];
16
+ } else if (command.channelType?.length > 0 || command.channelType) {
17
+ if (!Array.isArray(command.channelType)) command.channelType = [command.channelType];
22
18
  if (!command?.channelType?.includes(action.channel?.type)) {
23
19
  res = true;
24
20
  emit(client, action, command, 'Not the correct channel', command.channelType);
25
21
  }
26
- }
27
- else if (command.channels?.length > 0 && !command.channels.includes(action.channel?.id)) {
22
+ } else if (command.channels?.length > 0 && !command.channels.includes(action.channel?.id)) {
28
23
  res = true;
29
24
  emit(client, action, command, 'Not a whitelisted channel', command.channels);
30
- }
31
- else if (command.guilds?.length > 0 && !command.guilds.includes(action.guild?.id)) {
25
+ } else if (command.guilds?.length > 0 && !command.guilds.includes(action.guild?.id)) {
32
26
  res = true;
33
27
  emit(client, action, command, 'Not a whitelisted guild', command.guilds);
34
- }
35
- else if (command.channelType && command.channelType !== action.channel?.type) {
28
+ } else if (command.channelType && command.channelType !== action.channel?.type) {
36
29
  res = true;
37
30
  emit(client, action, command, 'Not the correct type of channel', command.channelType);
38
- }
39
- else if (action?.guild && (command.permissions?.user || client.settings.permissions?.user)) {
40
- const permissions = command.permissions?.user || client?.settings?.permissions?.user?.push(...handlerPermissions(client, command.commandType, 'user')), missing = [];
31
+ } else if (action?.guild && (command.permissions?.user || client.settings.permissions?.user)) {
32
+ const permissions = command.permissions?.user || client?.settings?.permissions?.user?.push(...handlerPermissions(client, command.commandType, 'user')),
33
+ missing = [];
41
34
  if (Array.isArray(permissions))
42
35
  permissions.map((permission) => {
43
36
  if (!(action.member?.permissions).has(permission)) {
@@ -48,9 +41,9 @@ export default function commandValidation(action, command, client, res = false)
48
41
  res = true;
49
42
  emit(client, action, command, 'Missing User Permissions', missing);
50
43
  }
51
- }
52
- else if (action?.guild && (command.permissions?.client || client.settings.permissions?.client)) {
53
- const permissions = command.permissions?.client || client?.settings?.permissions?.client?.push(...handlerPermissions(client, command.commandType, 'client')), missing = [];
44
+ } else if (action?.guild && (command.permissions?.client || client.settings.permissions?.client)) {
45
+ const permissions = command.permissions?.client || client?.settings?.permissions?.client?.push(...handlerPermissions(client, command.commandType, 'client')),
46
+ missing = [];
54
47
  if (Array.isArray(permissions))
55
48
  permissions.map((permission) => {
56
49
  if (!(action.member?.permissions).has(permission)) {
@@ -64,13 +57,15 @@ export default function commandValidation(action, command, client, res = false)
64
57
  }
65
58
  return res;
66
59
  }
60
+ exports.default = commandValidation;
67
61
  function emit(client, action, command, reason, extra) {
68
62
  return client.emit('commandBlock', action, command, reason, extra);
69
63
  }
70
64
  function inCooldown(user, client, command, action) {
71
- let res = false, downs = {};
65
+ let res = false,
66
+ downs = {};
72
67
  const { cooldowns, messageCommands, slashCommands, contextCommands, commands } = client.cache;
73
- if (command.commandType === CommandType.MessageCommand && client.handlerOptions.message.cooldown) {
68
+ if (command.commandType === enums_js_1.CommandType.MessageCommand && client.handlerOptions.message.cooldown) {
74
69
  if (messageCommands.has(user.id)) {
75
70
  const usr = messageCommands.get(user.id);
76
71
  usr.timeRemaining = usr.endsAt - Date.now();
@@ -84,7 +79,7 @@ function inCooldown(user, client, command, action) {
84
79
  }, client.handlerOptions.message.cooldown);
85
80
  }
86
81
  }
87
- if (command.commandType === CommandType.SlashCommand && client.handlerOptions.slash.cooldown) {
82
+ if (command.commandType === enums_js_1.CommandType.SlashCommand && client.handlerOptions.slash.cooldown) {
88
83
  if (slashCommands.has(user.id)) {
89
84
  const usr = slashCommands.get(user.id);
90
85
  usr.timeRemaining = usr.endsAt - Date.now();
@@ -98,7 +93,7 @@ function inCooldown(user, client, command, action) {
98
93
  }, client.handlerOptions.slash.cooldown);
99
94
  }
100
95
  }
101
- if (command.commandType === CommandType.ContextCommand && client.handlerOptions.context.cooldown) {
96
+ if (command.commandType === enums_js_1.CommandType.ContextCommand && client.handlerOptions.context.cooldown) {
102
97
  if (contextCommands.has(user.id)) {
103
98
  const usr = contextCommands.get(user.id);
104
99
  usr.timeRemaining = usr.endsAt - Date.now();
@@ -141,8 +136,7 @@ function inCooldown(user, client, command, action) {
141
136
  }, command.cooldown);
142
137
  }
143
138
  }
144
- if (Object.keys(downs).length > 0)
145
- client.emit('commandCooldown', action, command, downs);
139
+ if (Object.keys(downs).length > 0) client.emit('commandCooldown', action, command, downs);
146
140
  return res;
147
141
  }
148
142
  function toCooldown(action, command, cooldown, name) {
@@ -161,23 +155,15 @@ function toCooldown(action, command, cooldown, name) {
161
155
  }
162
156
  function handlerPermissions(client, commandType, type) {
163
157
  let permissions = [];
164
- if (commandType === CommandType.MessageCommand) {
165
- if (type === 'user')
166
- permissions = client.handlerOptions.message?.userPermissions || [];
167
- else if (type === 'client')
168
- permissions = client.handlerOptions.message?.clientPermissions || [];
169
- }
170
- else if (commandType === CommandType.SlashCommand) {
171
- if (type === 'user')
172
- permissions = client.handlerOptions.slash?.userPermissions || [];
173
- else if (type === 'client')
174
- permissions = client.handlerOptions.slash?.clientPermissions || [];
175
- }
176
- else if (commandType === CommandType.ContextCommand) {
177
- if (type === 'user')
178
- permissions = client.handlerOptions.context?.userPermissions || [];
179
- else if (type === 'client')
180
- permissions = client.handlerOptions.context?.clientPermissions || [];
158
+ if (commandType === enums_js_1.CommandType.MessageCommand) {
159
+ if (type === 'user') permissions = client.handlerOptions.message?.userPermissions || [];
160
+ else if (type === 'client') permissions = client.handlerOptions.message?.clientPermissions || [];
161
+ } else if (commandType === enums_js_1.CommandType.SlashCommand) {
162
+ if (type === 'user') permissions = client.handlerOptions.slash?.userPermissions || [];
163
+ else if (type === 'client') permissions = client.handlerOptions.slash?.clientPermissions || [];
164
+ } else if (commandType === enums_js_1.CommandType.ContextCommand) {
165
+ if (type === 'user') permissions = client.handlerOptions.context?.userPermissions || [];
166
+ else if (type === 'client') permissions = client.handlerOptions.context?.clientPermissions || [];
181
167
  }
182
168
  return permissions;
183
169
  }
@@ -1,5 +1,8 @@
1
- import { InhibitorType } from '../types/enums.js';
2
- export class InhibitorValidation {
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
+ exports.InhibitorValidation = void 0;
4
+ const enums_js_1 = require('../types/enums.js');
5
+ class InhibitorValidation {
3
6
  client;
4
7
  action;
5
8
  command;
@@ -13,23 +16,17 @@ export class InhibitorValidation {
13
16
  async inhibit() {
14
17
  for (const inhibitor of this.client.inhibitors) {
15
18
  const inhibit = inhibitor[1];
16
- if (inhibit)
17
- this.inhibited[inhibit.name] = await inhibit.check(this.action, this.args(this.action, inhibit.type));
19
+ if (inhibit) this.inhibited[inhibit.name] = await inhibit.check(this.action, this.args(this.action, inhibit.type));
18
20
  }
19
21
  for (const inhibit of Object.values(this.inhibited)) {
20
- if (inhibit)
21
- return this.inhibited;
22
+ if (inhibit) return this.inhibited;
22
23
  }
23
24
  }
24
25
  args(action, type) {
25
- if (type === InhibitorType.Channel)
26
- return action.channel;
27
- if (type === InhibitorType.User)
28
- return action.author || action.user;
29
- if (type === InhibitorType.Guild)
30
- return action.guild;
31
- if (type === InhibitorType.Member)
32
- return action.member;
26
+ if (type === enums_js_1.InhibitorType.Channel) return action.channel;
27
+ if (type === enums_js_1.InhibitorType.User) return action.author || action.user;
28
+ if (type === enums_js_1.InhibitorType.Guild) return action.guild;
29
+ if (type === enums_js_1.InhibitorType.Member) return action.member;
33
30
  // if (type === InhibitorType.Command)
34
31
  // return this.client.util.getAllCommands().filter(this.command.name);
35
32
  // if (type === InhibitorType.MessageCommand)
@@ -40,3 +37,4 @@ export class InhibitorValidation {
40
37
  // return this.client.util.getAllContextCommands().find(this.command.name);
41
38
  }
42
39
  }
40
+ exports.InhibitorValidation = InhibitorValidation;
@@ -0,0 +1,63 @@
1
+ import { ContextMenuCommandBuilder, Interaction } from 'discord.js';
2
+ import { ContextCommandOptions } from '../types/options.js';
3
+ import XernerxClient from '../client/XernerxClient.js';
4
+ /**
5
+ * @description The command builder for context commands.
6
+ * @param {String} id - The unique ID of the command.
7
+ * @param {ContextCommandOptions} options - The command options.
8
+ */
9
+ export default class ContextCommandBuilder {
10
+ id: string;
11
+ data: ContextMenuCommandBuilder;
12
+ name: string;
13
+ type: import('@discordjs/builders').ContextMenuCommandType;
14
+ description: string | undefined;
15
+ info: string | undefined;
16
+ category: string | undefined;
17
+ channelType: number | number[] | undefined;
18
+ cooldown: number | undefined;
19
+ ignore:
20
+ | {
21
+ owner?: boolean | undefined;
22
+ users?: string[] | undefined;
23
+ channels?: string[] | undefined;
24
+ guilds?: string[] | undefined;
25
+ }
26
+ | undefined;
27
+ strict:
28
+ | {
29
+ owner?: boolean | undefined;
30
+ users?: string[] | undefined;
31
+ channels?: string[] | undefined;
32
+ guilds?: string[] | undefined;
33
+ }
34
+ | undefined;
35
+ permissions:
36
+ | {
37
+ client?: string[] | undefined;
38
+ users?: string[] | undefined;
39
+ dm?: boolean | undefined;
40
+ }
41
+ | undefined;
42
+ defer:
43
+ | {
44
+ reply?: boolean | undefined;
45
+ ephemeral?: boolean | undefined;
46
+ fetch?: boolean | undefined;
47
+ }
48
+ | undefined;
49
+ client: typeof XernerxClient;
50
+ constructor(id: string, options: ContextCommandOptions);
51
+ /**
52
+ * @param {Interaction} interaction - The Discord interaction event data.
53
+ * @description make any preconditions here.
54
+ * TODO - update description
55
+ */
56
+ conditions(interaction: Interaction, args: any): Promise<void>;
57
+ /**
58
+ * @param {Interaction} interaction - The Discord interaction event data.
59
+ * @description Make your custom command here.
60
+ * TODO - update description
61
+ */
62
+ exec(interaction: Interaction, args: any): Promise<void>;
63
+ }
@@ -0,0 +1,97 @@
1
+ 'use strict';
2
+ var __importDefault =
3
+ (this && this.__importDefault) ||
4
+ function (mod) {
5
+ return mod && mod.__esModule ? mod : { default: mod };
6
+ };
7
+ Object.defineProperty(exports, '__esModule', { value: true });
8
+ const discord_js_1 = require('discord.js');
9
+ const zod_1 = require('zod');
10
+ const XernerxClient_js_1 = __importDefault(require('../client/XernerxClient.js'));
11
+ /**
12
+ * @description The command builder for context commands.
13
+ * @param {String} id - The unique ID of the command.
14
+ * @param {ContextCommandOptions} options - The command options.
15
+ */
16
+ class ContextCommandBuilder {
17
+ id;
18
+ data;
19
+ name;
20
+ type;
21
+ description;
22
+ info;
23
+ category;
24
+ channelType;
25
+ cooldown;
26
+ ignore;
27
+ strict;
28
+ permissions;
29
+ defer;
30
+ client;
31
+ constructor(id, options) {
32
+ this.id = id;
33
+ this.data = new discord_js_1.ContextMenuCommandBuilder();
34
+ if (options.name) this.data.setName(options.name);
35
+ if (options.type) this.data.setType(options.type);
36
+ if (options.permissions?.users) this.data.setDefaultMemberPermissions(options.permissions?.users);
37
+ if (options.permissions?.dm === false) this.data.setDMPermission(options.permissions?.dm);
38
+ if (options.nameLocalizations) this.data.setNameLocalizations(options.nameLocalizations);
39
+ zod_1.z
40
+ .object({
41
+ description: zod_1.z.string(),
42
+ info: zod_1.z.string(),
43
+ category: zod_1.z.string(),
44
+ channelType: zod_1.z.array(zod_1.z.number()).or(zod_1.z.number()),
45
+ cooldown: zod_1.z.number(),
46
+ ignore: zod_1.z.object({
47
+ owner: zod_1.z.boolean(),
48
+ users: zod_1.z.array(zod_1.z.string()),
49
+ channels: zod_1.z.array(zod_1.z.string()),
50
+ guilds: zod_1.z.array(zod_1.z.string()),
51
+ }),
52
+ strict: zod_1.z.object({
53
+ owner: zod_1.z.boolean(),
54
+ users: zod_1.z.array(zod_1.z.string()),
55
+ channels: zod_1.z.array(zod_1.z.string()),
56
+ guilds: zod_1.z.array(zod_1.z.string()),
57
+ }),
58
+ permissions: zod_1.z.object({
59
+ client: zod_1.z.array(zod_1.z.string()),
60
+ users: zod_1.z.array(zod_1.z.string()),
61
+ dm: zod_1.z.boolean(),
62
+ }),
63
+ defer: zod_1.z.object({
64
+ reply: zod_1.z.boolean(),
65
+ ephemeral: zod_1.z.boolean(),
66
+ fetch: zod_1.z.boolean(),
67
+ }),
68
+ })
69
+ .deepPartial()
70
+ .parse(options);
71
+ this.name = options.name;
72
+ this.type = options.type;
73
+ this.description = options.description;
74
+ this.info = options.info;
75
+ this.category = options.category;
76
+ this.channelType = options.channelType;
77
+ this.cooldown = options.cooldown;
78
+ this.ignore = options.ignore;
79
+ this.strict = options.strict;
80
+ this.permissions = options.permissions;
81
+ this.defer = options.defer;
82
+ this.client = XernerxClient_js_1.default;
83
+ }
84
+ /**
85
+ * @param {Interaction} interaction - The Discord interaction event data.
86
+ * @description make any preconditions here.
87
+ * TODO - update description
88
+ */
89
+ async conditions(interaction, args) {}
90
+ /**
91
+ * @param {Interaction} interaction - The Discord interaction event data.
92
+ * @description Make your custom command here.
93
+ * TODO - update description
94
+ */
95
+ async exec(interaction, args) {}
96
+ }
97
+ exports.default = ContextCommandBuilder;