xernerx 3.5.1 → 3.5.2

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 (113) hide show
  1. package/dist/{build → cjs/build}/ContextCommandBuilder.d.ts +36 -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/cjs/client/XernerxClient.js +116 -0
  11. package/dist/{handlers → cjs/handlers}/CommandHandler.js +11 -8
  12. package/dist/{handlers → cjs/handlers}/EventHandler.js +6 -3
  13. package/dist/cjs/handlers/Handler.js +308 -0
  14. package/dist/{handlers → cjs/handlers}/InhibitorHandler.js +6 -3
  15. package/dist/{main.d.ts → cjs/main.d.ts} +15 -1
  16. package/dist/cjs/main.js +112 -0
  17. package/dist/{models → cjs/models}/CommandArguments.d.ts +1 -1
  18. package/dist/{models → cjs/models}/CommandArguments.js +37 -52
  19. package/dist/cjs/models/Events.js +307 -0
  20. package/dist/cjs/models/Extensions.js +26 -0
  21. package/dist/{tools → cjs/tools}/XernerxError.js +4 -1
  22. package/dist/{tools → cjs/tools}/package.js +8 -6
  23. package/dist/cjs/types/enums.d.ts +44 -0
  24. package/dist/cjs/types/enums.js +38 -0
  25. package/dist/cjs/types/interfaces.js +2 -0
  26. package/dist/cjs/types/options.js +2 -0
  27. package/dist/{types → cjs/types}/types.d.ts +36 -9
  28. package/dist/cjs/types/types.js +2 -0
  29. package/dist/{utils → cjs/utils}/ClientUtil.js +73 -84
  30. package/dist/{utils → cjs/utils}/CommandUtil.d.ts +4 -2
  31. package/dist/{utils → cjs/utils}/CommandUtil.js +102 -103
  32. package/dist/{validators → cjs/validators}/CommandValidations.d.ts +6 -1
  33. package/dist/{validators → cjs/validators}/CommandValidations.js +36 -50
  34. package/dist/{validators → cjs/validators}/InhibitorValidations.js +12 -14
  35. package/dist/mjs/build/ContextCommandBuilder.d.ts +68 -0
  36. package/dist/mjs/build/ContextCommandBuilder.js +97 -0
  37. package/dist/mjs/build/EventBuilder.d.ts +21 -0
  38. package/dist/mjs/build/EventBuilder.js +44 -0
  39. package/dist/mjs/build/InhibitorBuilder.d.ts +19 -0
  40. package/dist/mjs/build/InhibitorBuilder.js +37 -0
  41. package/dist/mjs/build/MessageCommandBuilder.d.ts +59 -0
  42. package/dist/mjs/build/MessageCommandBuilder.js +100 -0
  43. package/dist/mjs/build/SlashCommandBuilder.d.ts +65 -0
  44. package/dist/mjs/build/SlashCommandBuilder.js +169 -0
  45. package/dist/mjs/client/XernerxClient.d.ts +28 -0
  46. package/dist/mjs/client/XernerxClient.js +116 -0
  47. package/dist/mjs/handlers/CommandHandler.d.ts +27 -0
  48. package/dist/mjs/handlers/CommandHandler.js +45 -0
  49. package/dist/mjs/handlers/EventHandler.d.ts +13 -0
  50. package/dist/mjs/handlers/EventHandler.js +19 -0
  51. package/dist/mjs/handlers/Handler.d.ts +57 -0
  52. package/dist/mjs/handlers/Handler.js +308 -0
  53. package/dist/mjs/handlers/InhibitorHandler.d.ts +18 -0
  54. package/dist/mjs/handlers/InhibitorHandler.js +24 -0
  55. package/dist/{main.js → mjs/main.d.ts} +20 -18
  56. package/dist/mjs/main.js +112 -0
  57. package/dist/mjs/models/CommandArguments.d.ts +17 -0
  58. package/dist/mjs/models/CommandArguments.js +106 -0
  59. package/dist/mjs/models/Events.d.ts +24 -0
  60. package/dist/mjs/models/Events.js +307 -0
  61. package/dist/mjs/models/Extensions.d.ts +7 -0
  62. package/dist/mjs/models/Extensions.js +26 -0
  63. package/dist/mjs/tools/XernerxError.d.ts +5 -0
  64. package/dist/mjs/tools/XernerxError.js +11 -0
  65. package/dist/mjs/tools/package.d.ts +49 -0
  66. package/dist/mjs/tools/package.js +50 -0
  67. package/dist/mjs/types/enums.d.ts +44 -0
  68. package/dist/mjs/types/enums.js +38 -0
  69. package/dist/mjs/types/interfaces.d.ts +25 -0
  70. package/dist/mjs/types/interfaces.js +2 -0
  71. package/dist/mjs/types/options.d.ts +241 -0
  72. package/dist/mjs/types/options.js +2 -0
  73. package/dist/mjs/types/types.d.ts +61 -0
  74. package/dist/mjs/types/types.js +2 -0
  75. package/dist/mjs/utils/ClientUtil.d.ts +25 -0
  76. package/dist/mjs/utils/ClientUtil.js +211 -0
  77. package/dist/mjs/utils/CommandUtil.d.ts +58 -0
  78. package/dist/mjs/utils/CommandUtil.js +247 -0
  79. package/dist/mjs/validators/CommandValidations.d.ts +12 -0
  80. package/dist/mjs/validators/CommandValidations.js +169 -0
  81. package/dist/mjs/validators/InhibitorValidations.d.ts +11 -0
  82. package/dist/mjs/validators/InhibitorValidations.js +40 -0
  83. package/package.json +10 -15
  84. package/dist/build/ContextCommandBuilder.js +0 -93
  85. package/dist/build/EventBuilder.js +0 -34
  86. package/dist/build/InhibitorBuilder.js +0 -27
  87. package/dist/build/MessageCommandBuilder.js +0 -90
  88. package/dist/build/SlashCommandBuilder.js +0 -125
  89. package/dist/client/XernerxClient.js +0 -101
  90. package/dist/handlers/Handler.js +0 -250
  91. package/dist/main.cjs +0 -2023
  92. package/dist/models/Events.js +0 -294
  93. package/dist/models/Extensions.js +0 -23
  94. package/dist/types/enums.d.ts +0 -35
  95. package/dist/types/enums.js +0 -35
  96. package/dist/types/interfaces.js +0 -1
  97. package/dist/types/options.js +0 -1
  98. package/dist/types/types.js +0 -1
  99. package/dist/validators/Shapes.js +0 -1
  100. /package/dist/{build → cjs/build}/EventBuilder.d.ts +0 -0
  101. /package/dist/{client → cjs/client}/XernerxClient.d.ts +0 -0
  102. /package/dist/{handlers → cjs/handlers}/CommandHandler.d.ts +0 -0
  103. /package/dist/{handlers → cjs/handlers}/EventHandler.d.ts +0 -0
  104. /package/dist/{handlers → cjs/handlers}/Handler.d.ts +0 -0
  105. /package/dist/{handlers → cjs/handlers}/InhibitorHandler.d.ts +0 -0
  106. /package/dist/{models → cjs/models}/Events.d.ts +0 -0
  107. /package/dist/{models → cjs/models}/Extensions.d.ts +0 -0
  108. /package/dist/{tools → cjs/tools}/XernerxError.d.ts +0 -0
  109. /package/dist/{tools → cjs/tools}/package.d.ts +0 -0
  110. /package/dist/{types → cjs/types}/interfaces.d.ts +0 -0
  111. /package/dist/{types → cjs/types}/options.d.ts +0 -0
  112. /package/dist/{utils → cjs/utils}/ClientUtil.d.ts +0 -0
  113. /package/dist/{validators → cjs/validators}/InhibitorValidations.d.ts +0 -0
@@ -21,14 +21,41 @@ export interface XernerxInteraction extends InteractionResponse {
21
21
  export interface XernerxUser extends User {
22
22
  isOwner: boolean;
23
23
  }
24
- export interface XernerxRole extends Role {
25
- }
26
- export interface XernerxTextChannel extends TextChannel {
27
- }
28
- export interface XernerxGuild extends Guild {
29
- }
30
- export interface XernerxMember extends GuildMember {
31
- }
24
+ export interface XernerxRole extends Role {}
25
+ export interface XernerxTextChannel extends TextChannel {}
26
+ export interface XernerxGuild extends Guild {}
27
+ export interface XernerxMember extends GuildMember {}
32
28
  export type MessageCommandArgsTypes = 'rest' | 'option' | 'flag' | 'string' | 'number' | 'channel' | 'user' | 'member' | 'boolean' | 'role';
33
- export type Localizations = 'id' | 'da' | 'de' | 'en-GB' | 'en-US' | 'es-ES' | 'fr' | 'hr' | 'it' | 'lt' | 'hu' | 'nl' | 'no' | 'pl' | 'pt-BR' | 'ro' | 'fi' | 'sv-SE' | 'vi' | 'tr' | 'cs' | 'el' | 'bg' | 'ru' | 'uk' | 'hi' | 'th' | 'zh-CN' | 'ja' | 'zh-TW' | 'ko';
29
+ export type Localizations =
30
+ | 'id'
31
+ | 'da'
32
+ | 'de'
33
+ | 'en-GB'
34
+ | 'en-US'
35
+ | 'es-ES'
36
+ | 'fr'
37
+ | 'hr'
38
+ | 'it'
39
+ | 'lt'
40
+ | 'hu'
41
+ | 'nl'
42
+ | 'no'
43
+ | 'pl'
44
+ | 'pt-BR'
45
+ | 'ro'
46
+ | 'fi'
47
+ | 'sv-SE'
48
+ | 'vi'
49
+ | 'tr'
50
+ | 'cs'
51
+ | 'el'
52
+ | 'bg'
53
+ | 'ru'
54
+ | 'uk'
55
+ | 'hi'
56
+ | 'th'
57
+ | 'zh-CN'
58
+ | 'ja'
59
+ | 'zh-TW'
60
+ | 'ko';
34
61
  export type EventEmitterType = 'client' | 'process';
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
@@ -1,12 +1,19 @@
1
- import XernerxError from '../tools/XernerxError.js';
2
- export class ClientUtil {
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.ClientUtil = void 0;
9
+ const XernerxError_js_1 = __importDefault(require('../tools/XernerxError.js'));
10
+ class ClientUtil {
3
11
  client;
4
12
  constructor(client) {
5
13
  this.client = client;
6
14
  }
7
15
  uptime(timestamp) {
8
- if (!timestamp)
9
- timestamp = this.client.uptime || 0;
16
+ if (!timestamp) timestamp = this.client.uptime || 0;
10
17
  let totalSeconds = timestamp / 1000;
11
18
  let years = Math.floor(totalSeconds / 31536000);
12
19
  totalSeconds %= 31536000;
@@ -16,90 +23,77 @@ export class ClientUtil {
16
23
  totalSeconds %= 3600;
17
24
  let minutes = Math.floor(totalSeconds / 60);
18
25
  let seconds = Math.floor(totalSeconds % 60);
19
- if (years >= 1)
20
- return `${years}y ${days}d ${hours}h ${minutes}m`;
21
- else if (days >= 1)
22
- return `${days}d ${hours}h ${minutes}m`;
23
- else if (hours >= 1)
24
- return `${hours}h ${minutes}m`;
25
- else if (minutes >= 1)
26
- return `${minutes}m ${seconds}s`;
27
- else
28
- return `${seconds}s`;
26
+ if (years >= 1) return `${years}y ${days}d ${hours}h ${minutes}m`;
27
+ else if (days >= 1) return `${days}d ${hours}h ${minutes}m`;
28
+ else if (hours >= 1) return `${hours}h ${minutes}m`;
29
+ else if (minutes >= 1) return `${minutes}m ${seconds}s`;
30
+ else return `${seconds}s`;
29
31
  }
30
32
  getSubcommands(name) {
31
- if (!name || typeof name !== 'string')
32
- throw new XernerxError(`Expected name to be of type string, received ${typeof name} instead!`);
33
+ if (!name || typeof name !== 'string') throw new XernerxError_js_1.default(`Expected name to be of type string, received ${typeof name} instead!`);
33
34
  const commands = [];
34
35
  this.getAllCommands()
35
36
  .filter((c) => (c.data?.name?.toLowerCase() || c.name?.toLowerCase()) == name?.toLowerCase())
36
37
  .map((c) => {
37
- if (c?.data?.options?.length > 0) {
38
- c?.data?.options?.map((option) => {
39
- if (!option?.type) {
40
- if (option?.options?.length > 0) {
41
- option?.options?.map((opt) => {
42
- if (!opt.type) {
43
- commands.push({
44
- name: c.data.name,
45
- formattedName: `${c.data.name} ${option.name} ${opt.name}`,
46
- description: opt.description,
47
- category: c.category || null,
48
- commandType: c.commandType,
49
- });
50
- }
51
- else {
52
- commands.push({
53
- name: c.data.name,
54
- formattedName: `${c.data.name} ${option.name}`,
55
- description: option.description,
56
- category: c.category || null,
57
- commandType: c.commandType,
58
- });
59
- }
60
- });
61
- }
62
- else {
38
+ if (c?.data?.options?.length > 0) {
39
+ c?.data?.options?.map((option) => {
40
+ if (!option?.type) {
41
+ if (option?.options?.length > 0) {
42
+ option?.options?.map((opt) => {
43
+ if (!opt.type) {
44
+ commands.push({
45
+ name: c.data.name,
46
+ formattedName: `${c.data.name} ${option.name} ${opt.name}`,
47
+ description: opt.description,
48
+ category: c.category || null,
49
+ commandType: c.commandType,
50
+ });
51
+ } else {
52
+ commands.push({
53
+ name: c.data.name,
54
+ formattedName: `${c.data.name} ${option.name}`,
55
+ description: option.description,
56
+ category: c.category || null,
57
+ commandType: c.commandType,
58
+ });
59
+ }
60
+ });
61
+ } else {
62
+ commands.push({
63
+ name: c.data.name,
64
+ formattedName: `${c.data.name} ${option.name}`,
65
+ description: option.description,
66
+ category: c.category || null,
67
+ commandType: c.commandType,
68
+ });
69
+ }
70
+ } else {
63
71
  commands.push({
64
72
  name: c.data.name,
65
- formattedName: `${c.data.name} ${option.name}`,
66
- description: option.description,
73
+ formattedName: `${c.data.name}`,
74
+ description: c.data.description,
67
75
  category: c.category || null,
68
76
  commandType: c.commandType,
69
77
  });
70
78
  }
71
- }
72
- else {
73
- commands.push({
74
- name: c.data.name,
75
- formattedName: `${c.data.name}`,
76
- description: c.data.description,
77
- category: c.category || null,
78
- commandType: c.commandType,
79
- });
80
- }
81
- });
82
- }
83
- else {
84
- commands.push({
85
- name: c.data?.name || c.name,
86
- formattedName: `${c.data?.name || c.name}`,
87
- description: c.data?.description || c.description,
88
- category: c.category || null,
89
- commandType: c.commandType,
90
- });
91
- }
92
- });
79
+ });
80
+ } else {
81
+ commands.push({
82
+ name: c.data?.name || c.name,
83
+ formattedName: `${c.data?.name || c.name}`,
84
+ description: c.data?.description || c.description,
85
+ category: c.category || null,
86
+ commandType: c.commandType,
87
+ });
88
+ }
89
+ });
93
90
  return commands;
94
91
  }
95
92
  isOwner(userId) {
96
- if (!userId)
97
- throw new XernerxError('No ID specified');
93
+ if (!userId) throw new XernerxError_js_1.default('No ID specified');
98
94
  let owners = this.client.settings.ownerId;
99
- if (!owners)
100
- return false;
101
- if (typeof owners === 'string')
102
- owners = [owners];
95
+ if (!owners) return false;
96
+ if (typeof owners === 'string') owners = [owners];
103
97
  return owners.includes(userId);
104
98
  }
105
99
  getAllCommands() {
@@ -148,8 +142,7 @@ export class ClientUtil {
148
142
  getCooldowns(id, command) {
149
143
  let cooldowns = [];
150
144
  for (const [key, value] of Object.entries(this.client.cache)) {
151
- if (!['cooldowns', 'messageCommands', 'slashCommands', 'contextCommands', 'commands'].includes(key))
152
- continue;
145
+ if (!['cooldowns', 'messageCommands', 'slashCommands', 'contextCommands', 'commands'].includes(key)) continue;
153
146
  if (key === 'commands') {
154
147
  if (command) {
155
148
  value.map((x) => {
@@ -159,16 +152,14 @@ export class ClientUtil {
159
152
  cooldowns.push(x);
160
153
  }
161
154
  });
162
- }
163
- else {
155
+ } else {
164
156
  value.map((x) => {
165
157
  if (x.name.split(/-/).shift() === id) {
166
158
  cooldowns.push(x);
167
159
  }
168
160
  });
169
161
  }
170
- }
171
- else {
162
+ } else {
172
163
  if (value.has(id)) {
173
164
  const x = value.get(id);
174
165
  cooldowns.push(x);
@@ -180,8 +171,7 @@ export class ClientUtil {
180
171
  getCooldownTimers(id, command) {
181
172
  let cooldowns = [];
182
173
  for (const [key, value] of Object.entries(this.client.cache)) {
183
- if (!['cooldowns', 'messageCommands', 'slashCommands', 'contextCommands', 'commands'].includes(key))
184
- continue;
174
+ if (!['cooldowns', 'messageCommands', 'slashCommands', 'contextCommands', 'commands'].includes(key)) continue;
185
175
  if (key === 'commands') {
186
176
  if (command) {
187
177
  value.map((x) => {
@@ -193,8 +183,7 @@ export class ClientUtil {
193
183
  });
194
184
  }
195
185
  });
196
- }
197
- else {
186
+ } else {
198
187
  value.map((x) => {
199
188
  if (x.name.split(/-/).shift() === id) {
200
189
  cooldowns.push({
@@ -203,8 +192,7 @@ export class ClientUtil {
203
192
  }
204
193
  });
205
194
  }
206
- }
207
- else {
195
+ } else {
208
196
  if (value.has(id)) {
209
197
  const x = value.get(id);
210
198
  cooldowns.push({ [key]: x.endsAt - Date.now() });
@@ -220,3 +208,4 @@ export class ClientUtil {
220
208
  return new Promise((resolve) => setTimeout(resolve, time || 0));
221
209
  }
222
210
  }
211
+ exports.ClientUtil = ClientUtil;
@@ -31,7 +31,7 @@ export declare class MessageCommandUtil {
31
31
  reply(content: MessagePayload | string): Promise<Message<boolean> | undefined>;
32
32
  send(content: MessagePayload | string): Promise<Message<true> | Message<false> | undefined>;
33
33
  defer(time: number): Promise<unknown>;
34
- getCommands(): import("@discordjs/collection").Collection<string, import("../main.js").MessageCommandBuilder>;
34
+ getCommands(): import('@discordjs/collection').Collection<string, import('../main.js').MessageCommandBuilder>;
35
35
  getCommandName(): void;
36
36
  selectMenuPaginator(embeds: Array<EmbedBuilder>, options?: SelectMenuOptions): void;
37
37
  buttonPaginator(embeds: Array<EmbedBuilder>, options: ButtonOptions): void;
@@ -45,7 +45,9 @@ export declare class InteractionCommandUtil {
45
45
  constructor(client: XernerxClient, interaction: Interaction);
46
46
  reply(content: MessagePayload | string): any;
47
47
  defer(time: number): Promise<unknown>;
48
- getCommands(): import("@discordjs/collection").Collection<string, import("../main.js").SlashCommandBuilder> | import("@discordjs/collection").Collection<string, import("../main.js").ContextCommandBuilder>;
48
+ getCommands():
49
+ | import('@discordjs/collection').Collection<string, import('../main.js').SlashCommandBuilder>
50
+ | import('@discordjs/collection').Collection<string, import('../main.js').ContextCommandBuilder>;
49
51
  getCommandName(): void;
50
52
  selectMenuPaginator(embeds: Array<EmbedBuilder>, options?: SelectMenuOptions): void;
51
53
  buttonPaginator(embeds: Array<EmbedBuilder>, options: ButtonOptions): void;
@@ -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;