xernerx 3.5.2 → 4.0.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 (194) hide show
  1. package/dist/build/ContextCommandBuilder.d.ts +47 -0
  2. package/dist/build/ContextCommandBuilder.js +78 -0
  3. package/dist/{cjs/build → build}/EventBuilder.d.ts +7 -6
  4. package/dist/build/EventBuilder.js +35 -0
  5. package/dist/build/InhibitorBuilder.d.ts +17 -0
  6. package/dist/build/InhibitorBuilder.js +26 -0
  7. package/dist/build/MessageCommandBuilder.d.ts +43 -0
  8. package/dist/build/MessageCommandBuilder.js +71 -0
  9. package/dist/{cjs/build → build}/SlashCommandBuilder.d.ts +16 -31
  10. package/dist/build/SlashCommandBuilder.js +122 -0
  11. package/dist/build copy/ContextCommandBuilder.d.ts +37 -0
  12. package/dist/build copy/ContextCommandBuilder.js +88 -0
  13. package/dist/{mjs/build/EventBuilder.d.ts → build copy/EventBuilder.d.ts } +4 -4
  14. package/dist/build copy/EventBuilder.js +34 -0
  15. package/dist/{cjs/build/InhibitorBuilder.d.ts → build copy/InhibitorBuilder.d.ts } +2 -2
  16. package/dist/build copy/InhibitorBuilder.js +27 -0
  17. package/dist/{cjs/build/MessageCommandBuilder.d.ts → build copy/MessageCommandBuilder.d.ts } +14 -34
  18. package/dist/build copy/MessageCommandBuilder.js +90 -0
  19. package/dist/build copy/SlashCommandBuilder.d.ts +41 -0
  20. package/dist/build copy/SlashCommandBuilder.js +122 -0
  21. package/dist/client/DBLClient.d.ts +8 -0
  22. package/dist/client/DBLClient.js +15 -0
  23. package/dist/client/Top.ggClient.d.ts +1 -0
  24. package/dist/client/Top.ggClient.js +1 -0
  25. package/dist/client/XernerxClient.d.ts +54 -0
  26. package/dist/client/XernerxClient.js +90 -0
  27. package/dist/events/messageCreate.d.ts +1 -0
  28. package/dist/events/messageCreate.js +1 -0
  29. package/dist/functions/AsyncFunctions.d.ts +1 -0
  30. package/dist/functions/AsyncFunctions.js +1 -0
  31. package/dist/functions/delay.d.ts +1 -0
  32. package/dist/functions/delay.js +3 -0
  33. package/dist/functions/deploy.d.ts +2 -0
  34. package/dist/functions/deploy.js +29 -0
  35. package/dist/functions/getPermissionBitField.d.ts +2 -0
  36. package/dist/functions/getPermissionBitField.js +17 -0
  37. package/dist/functions/hasVoted.d.ts +1 -0
  38. package/dist/functions/hasVoted.js +1 -0
  39. package/dist/functions/isOwner.d.ts +3 -0
  40. package/dist/functions/isOwner.js +3 -0
  41. package/dist/functions/isVoter.d.ts +3 -0
  42. package/dist/functions/isVoter.js +5 -0
  43. package/dist/functions/load.d.ts +3 -0
  44. package/dist/functions/load.js +32 -0
  45. package/dist/functions/reload.d.ts +2 -0
  46. package/dist/functions/reload.js +39 -0
  47. package/dist/functions/sendWebhook.d.ts +2 -0
  48. package/dist/functions/sendWebhook.js +12 -0
  49. package/dist/functions/voted.d.ts +1 -0
  50. package/dist/functions/voted.js +1 -0
  51. package/dist/functions/xernerxUser.d.ts +3 -0
  52. package/dist/functions/xernerxUser.js +8 -0
  53. package/dist/handlers/CommandHandler.d.ts +13 -0
  54. package/dist/handlers/CommandHandler.js +220 -0
  55. package/dist/handlers/EventHandler.d.ts +7 -0
  56. package/dist/handlers/EventHandler.js +24 -0
  57. package/dist/handlers/ExtensionHandler.d.ts +7 -0
  58. package/dist/handlers/ExtensionHandler.js +19 -0
  59. package/dist/handlers/Handler.d.ts +14 -0
  60. package/dist/handlers/Handler.js +36 -0
  61. package/dist/handlers/InhibitorHandler.d.ts +7 -0
  62. package/dist/handlers/InhibitorHandler.js +24 -0
  63. package/dist/handlers/WebhookHandler.d.ts +7 -0
  64. package/dist/handlers/WebhookHandler.js +50 -0
  65. package/dist/main.d.ts +11 -0
  66. package/dist/main.js +11 -0
  67. package/dist/models/Arguments.d.ts +15 -0
  68. package/dist/models/Arguments.js +129 -0
  69. package/dist/{mjs/models → models}/CommandArguments.js +2 -7
  70. package/dist/{mjs/models → models}/Events.js +44 -54
  71. package/dist/models/Extensions.js +23 -0
  72. package/dist/models/XernerxUser.d.ts +2 -0
  73. package/dist/models/XernerxUser.js +9 -0
  74. package/dist/tools/XernerxError.d.ts +6 -0
  75. package/dist/tools/XernerxError.js +10 -0
  76. package/dist/tools/XernerxLog.d.ts +13 -0
  77. package/dist/tools/XernerxLog.js +30 -0
  78. package/dist/tools/classes.d.ts +6 -0
  79. package/dist/tools/classes.js +10 -0
  80. package/dist/tools/loggers.d.ts +4 -0
  81. package/dist/tools/loggers.js +4 -0
  82. package/dist/{cjs/tools → tools}/package.d.ts +5 -9
  83. package/dist/{cjs/tools → tools}/package.js +12 -18
  84. package/dist/{cjs/types → types}/enums.js +8 -11
  85. package/dist/types/extenders.d.ts +23 -0
  86. package/dist/types/extenders.js +1 -0
  87. package/dist/types/interfaces.d.ts +224 -0
  88. package/dist/types/interfaces.js +1 -0
  89. package/dist/{cjs/types → types}/options.d.ts +13 -0
  90. package/dist/types/options.js +1 -0
  91. package/dist/types/types.d.ts +181 -0
  92. package/dist/types/types.js +1 -0
  93. package/dist/utils/ClientUtil.d.ts +6 -0
  94. package/dist/utils/ClientUtil.js +7 -0
  95. package/dist/{cjs/utils → utils}/CommandUtil.js +14 -29
  96. package/dist/utils/InteractionArguments.d.ts +1 -0
  97. package/dist/utils/InteractionArguments.js +1 -0
  98. package/dist/utils/InteractionUtil.d.ts +10 -0
  99. package/dist/utils/InteractionUtil.js +15 -0
  100. package/dist/utils/MessageUtil.d.ts +11 -0
  101. package/dist/utils/MessageUtil.js +42 -0
  102. package/dist/utils/Util.d.ts +5 -0
  103. package/dist/utils/Util.js +6 -0
  104. package/dist/{mjs/validators → validators}/CommandValidations.js +11 -14
  105. package/dist/validators/InhibitorValidations.d.ts +18 -0
  106. package/dist/validators/InhibitorValidations.js +34 -0
  107. package/dist/validators/commandValidation.d.ts +6 -0
  108. package/dist/validators/commandValidation.js +48 -0
  109. package/dist/validators/commands.d.ts +4 -0
  110. package/dist/validators/commands.js +25 -0
  111. package/package.json +10 -13
  112. package/dist/cjs/build/ContextCommandBuilder.d.ts +0 -68
  113. package/dist/cjs/build/ContextCommandBuilder.js +0 -97
  114. package/dist/cjs/build/EventBuilder.js +0 -44
  115. package/dist/cjs/build/InhibitorBuilder.js +0 -37
  116. package/dist/cjs/build/MessageCommandBuilder.js +0 -100
  117. package/dist/cjs/build/SlashCommandBuilder.js +0 -169
  118. package/dist/cjs/client/XernerxClient.d.ts +0 -28
  119. package/dist/cjs/client/XernerxClient.js +0 -116
  120. package/dist/cjs/handlers/CommandHandler.d.ts +0 -27
  121. package/dist/cjs/handlers/CommandHandler.js +0 -45
  122. package/dist/cjs/handlers/EventHandler.d.ts +0 -13
  123. package/dist/cjs/handlers/EventHandler.js +0 -19
  124. package/dist/cjs/handlers/Handler.d.ts +0 -57
  125. package/dist/cjs/handlers/Handler.js +0 -308
  126. package/dist/cjs/handlers/InhibitorHandler.d.ts +0 -18
  127. package/dist/cjs/handlers/InhibitorHandler.js +0 -24
  128. package/dist/cjs/main.d.ts +0 -44
  129. package/dist/cjs/main.js +0 -112
  130. package/dist/cjs/models/CommandArguments.js +0 -106
  131. package/dist/cjs/models/Events.js +0 -307
  132. package/dist/cjs/models/Extensions.js +0 -26
  133. package/dist/cjs/tools/XernerxError.d.ts +0 -5
  134. package/dist/cjs/tools/XernerxError.js +0 -11
  135. package/dist/cjs/types/interfaces.d.ts +0 -25
  136. package/dist/cjs/types/interfaces.js +0 -2
  137. package/dist/cjs/types/options.js +0 -2
  138. package/dist/cjs/types/types.d.ts +0 -61
  139. package/dist/cjs/types/types.js +0 -2
  140. package/dist/cjs/utils/ClientUtil.d.ts +0 -25
  141. package/dist/cjs/utils/ClientUtil.js +0 -211
  142. package/dist/cjs/validators/CommandValidations.js +0 -169
  143. package/dist/cjs/validators/InhibitorValidations.d.ts +0 -11
  144. package/dist/cjs/validators/InhibitorValidations.js +0 -40
  145. package/dist/mjs/build/ContextCommandBuilder.d.ts +0 -68
  146. package/dist/mjs/build/ContextCommandBuilder.js +0 -97
  147. package/dist/mjs/build/EventBuilder.js +0 -44
  148. package/dist/mjs/build/InhibitorBuilder.d.ts +0 -19
  149. package/dist/mjs/build/InhibitorBuilder.js +0 -37
  150. package/dist/mjs/build/MessageCommandBuilder.d.ts +0 -59
  151. package/dist/mjs/build/MessageCommandBuilder.js +0 -100
  152. package/dist/mjs/build/SlashCommandBuilder.d.ts +0 -65
  153. package/dist/mjs/build/SlashCommandBuilder.js +0 -169
  154. package/dist/mjs/client/XernerxClient.d.ts +0 -28
  155. package/dist/mjs/client/XernerxClient.js +0 -116
  156. package/dist/mjs/handlers/CommandHandler.d.ts +0 -27
  157. package/dist/mjs/handlers/CommandHandler.js +0 -45
  158. package/dist/mjs/handlers/EventHandler.d.ts +0 -13
  159. package/dist/mjs/handlers/EventHandler.js +0 -19
  160. package/dist/mjs/handlers/Handler.d.ts +0 -57
  161. package/dist/mjs/handlers/Handler.js +0 -308
  162. package/dist/mjs/handlers/InhibitorHandler.d.ts +0 -18
  163. package/dist/mjs/handlers/InhibitorHandler.js +0 -24
  164. package/dist/mjs/main.d.ts +0 -44
  165. package/dist/mjs/main.js +0 -112
  166. package/dist/mjs/models/CommandArguments.d.ts +0 -17
  167. package/dist/mjs/models/Events.d.ts +0 -24
  168. package/dist/mjs/models/Extensions.d.ts +0 -7
  169. package/dist/mjs/models/Extensions.js +0 -26
  170. package/dist/mjs/tools/XernerxError.d.ts +0 -5
  171. package/dist/mjs/tools/XernerxError.js +0 -11
  172. package/dist/mjs/tools/package.d.ts +0 -49
  173. package/dist/mjs/tools/package.js +0 -50
  174. package/dist/mjs/types/enums.d.ts +0 -44
  175. package/dist/mjs/types/enums.js +0 -38
  176. package/dist/mjs/types/interfaces.d.ts +0 -25
  177. package/dist/mjs/types/interfaces.js +0 -2
  178. package/dist/mjs/types/options.d.ts +0 -241
  179. package/dist/mjs/types/options.js +0 -2
  180. package/dist/mjs/types/types.d.ts +0 -61
  181. package/dist/mjs/types/types.js +0 -2
  182. package/dist/mjs/utils/ClientUtil.d.ts +0 -25
  183. package/dist/mjs/utils/ClientUtil.js +0 -211
  184. package/dist/mjs/utils/CommandUtil.d.ts +0 -58
  185. package/dist/mjs/utils/CommandUtil.js +0 -247
  186. package/dist/mjs/validators/CommandValidations.d.ts +0 -12
  187. package/dist/mjs/validators/InhibitorValidations.d.ts +0 -11
  188. package/dist/mjs/validators/InhibitorValidations.js +0 -40
  189. /package/dist/{cjs/models → models}/CommandArguments.d.ts +0 -0
  190. /package/dist/{cjs/models → models}/Events.d.ts +0 -0
  191. /package/dist/{cjs/models → models}/Extensions.d.ts +0 -0
  192. /package/dist/{cjs/types → types}/enums.d.ts +0 -0
  193. /package/dist/{cjs/utils → utils}/CommandUtil.d.ts +0 -0
  194. /package/dist/{cjs/validators → validators}/CommandValidations.d.ts +0 -0
@@ -1,211 +0,0 @@
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 {
11
- client;
12
- constructor(client) {
13
- this.client = client;
14
- }
15
- uptime(timestamp) {
16
- if (!timestamp) timestamp = this.client.uptime || 0;
17
- let totalSeconds = timestamp / 1000;
18
- let years = Math.floor(totalSeconds / 31536000);
19
- totalSeconds %= 31536000;
20
- let days = Math.floor(totalSeconds / 86400);
21
- totalSeconds %= 86400;
22
- let hours = Math.floor(totalSeconds / 3600);
23
- totalSeconds %= 3600;
24
- let minutes = Math.floor(totalSeconds / 60);
25
- let seconds = Math.floor(totalSeconds % 60);
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`;
31
- }
32
- getSubcommands(name) {
33
- if (!name || typeof name !== 'string') throw new XernerxError_js_1.default(`Expected name to be of type string, received ${typeof name} instead!`);
34
- const commands = [];
35
- this.getAllCommands()
36
- .filter((c) => (c.data?.name?.toLowerCase() || c.name?.toLowerCase()) == name?.toLowerCase())
37
- .map((c) => {
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 {
71
- commands.push({
72
- name: c.data.name,
73
- formattedName: `${c.data.name}`,
74
- description: c.data.description,
75
- category: c.category || null,
76
- commandType: c.commandType,
77
- });
78
- }
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
- });
90
- return commands;
91
- }
92
- isOwner(userId) {
93
- if (!userId) throw new XernerxError_js_1.default('No ID specified');
94
- let owners = this.client.settings.ownerId;
95
- if (!owners) return false;
96
- if (typeof owners === 'string') owners = [owners];
97
- return owners.includes(userId);
98
- }
99
- getAllCommands() {
100
- const cmds = [];
101
- for (const commands of Object.values(this.client.commands)) {
102
- commands.map((cmd) => cmds.push(cmd));
103
- }
104
- return cmds;
105
- }
106
- getAllMessageCommands() {
107
- const cmds = [];
108
- this.client.commands.message.map((cmd) => cmds.push(cmd));
109
- return cmds;
110
- }
111
- getAllSlashCommands() {
112
- const cmds = [];
113
- this.client.commands.slash.map((cmd) => cmds.push(cmd));
114
- return cmds;
115
- }
116
- getAllContextCommands() {
117
- const cmds = [];
118
- this.client.commands.context.map((cmd) => cmds.push(cmd));
119
- return cmds;
120
- }
121
- setPresence(options) {
122
- const client = this.client;
123
- function pres() {
124
- client.user?.setPresence({
125
- activities: [
126
- {
127
- name: options.text || undefined,
128
- type: options.type || undefined,
129
- url: options.link || undefined,
130
- },
131
- ],
132
- status: options.status || undefined,
133
- });
134
- }
135
- pres();
136
- if (options.interval) {
137
- setInterval(() => {
138
- pres();
139
- }, options.interval);
140
- }
141
- }
142
- getCooldowns(id, command) {
143
- let cooldowns = [];
144
- for (const [key, value] of Object.entries(this.client.cache)) {
145
- if (!['cooldowns', 'messageCommands', 'slashCommands', 'contextCommands', 'commands'].includes(key)) continue;
146
- if (key === 'commands') {
147
- if (command) {
148
- value.map((x) => {
149
- const name = x.name.split(/-/);
150
- name.pop();
151
- if (name.join('-') === id + '-' + command) {
152
- cooldowns.push(x);
153
- }
154
- });
155
- } else {
156
- value.map((x) => {
157
- if (x.name.split(/-/).shift() === id) {
158
- cooldowns.push(x);
159
- }
160
- });
161
- }
162
- } else {
163
- if (value.has(id)) {
164
- const x = value.get(id);
165
- cooldowns.push(x);
166
- }
167
- }
168
- }
169
- return cooldowns;
170
- }
171
- getCooldownTimers(id, command) {
172
- let cooldowns = [];
173
- for (const [key, value] of Object.entries(this.client.cache)) {
174
- if (!['cooldowns', 'messageCommands', 'slashCommands', 'contextCommands', 'commands'].includes(key)) continue;
175
- if (key === 'commands') {
176
- if (command) {
177
- value.map((x) => {
178
- const name = x.name.split(/-/);
179
- name.pop();
180
- if (name.join('-') === id + '-' + command) {
181
- cooldowns.push({
182
- [x.commandName]: x.endsAt - Date.now(),
183
- });
184
- }
185
- });
186
- } else {
187
- value.map((x) => {
188
- if (x.name.split(/-/).shift() === id) {
189
- cooldowns.push({
190
- [x.commandName]: x.endsAt - Date.now(),
191
- });
192
- }
193
- });
194
- }
195
- } else {
196
- if (value.has(id)) {
197
- const x = value.get(id);
198
- cooldowns.push({ [key]: x.endsAt - Date.now() });
199
- }
200
- }
201
- }
202
- const sort = cooldowns.map((x) => Object.entries(x).shift()).sort((a, b) => b[1] - a[1]);
203
- cooldowns = [];
204
- sort.map(([key, value]) => cooldowns.push({ [key]: value }));
205
- return cooldowns;
206
- }
207
- async defer(time) {
208
- return new Promise((resolve) => setTimeout(resolve, time || 0));
209
- }
210
- }
211
- exports.ClientUtil = ClientUtil;
@@ -1,58 +0,0 @@
1
- import { ActionRowBuilder, ButtonBuilder, EmbedBuilder, Interaction, Message, MessagePayload, StringSelectMenuBuilder } from 'discord.js';
2
- import XernerxClient from '../client/XernerxClient.js';
3
- import { XernerxMessage } from '../types/types.js';
4
- interface SelectMenuOptions {
5
- index?: EmbedBuilder;
6
- row?: ActionRowBuilder;
7
- component?: StringSelectMenuBuilder;
8
- components?: object[];
9
- reply?: boolean;
10
- id?: string;
11
- filter?: Function;
12
- time?: number;
13
- ephemeral?: boolean;
14
- }
15
- interface ButtonOptions {
16
- index?: number;
17
- buttons?: Array<string>;
18
- reply?: boolean;
19
- row?: ActionRowBuilder;
20
- component?: ButtonBuilder;
21
- components?: object[];
22
- id?: string;
23
- filter?: any;
24
- time?: number;
25
- ephemeral?: boolean;
26
- }
27
- export declare class MessageCommandUtil {
28
- client: XernerxClient;
29
- message: XernerxMessage;
30
- constructor(client: XernerxClient, message: Message & XernerxMessage);
31
- reply(content: MessagePayload | string): Promise<Message<boolean> | undefined>;
32
- send(content: MessagePayload | string): Promise<Message<true> | Message<false> | undefined>;
33
- defer(time: number): Promise<unknown>;
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;
39
- isOwner(): boolean;
40
- createModal(): void;
41
- }
42
- export declare class InteractionCommandUtil {
43
- client: XernerxClient;
44
- interaction: any;
45
- constructor(client: XernerxClient, interaction: Interaction);
46
- reply(content: MessagePayload | string): any;
47
- defer(time: number): Promise<unknown>;
48
- getCommands():
49
- | import('@discordjs/collection').Collection<string, import('../main.js').SlashCommandBuilder>
50
- | import('@discordjs/collection').Collection<string, import('../main.js').ContextCommandBuilder>;
51
- getCommandName(): void;
52
- selectMenuPaginator(embeds: Array<EmbedBuilder>, options?: SelectMenuOptions): void;
53
- buttonPaginator(embeds: Array<EmbedBuilder>, options: ButtonOptions): void;
54
- buttonMenuPaginator(embeds: Array<EmbedBuilder>, options: ButtonOptions & SelectMenuOptions): void;
55
- isOwner(): boolean;
56
- createModal(): void;
57
- }
58
- export {};
@@ -1,247 +0,0 @@
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 {
12
- client;
13
- message;
14
- constructor(client, message) {
15
- this.client = client;
16
- this.message = message;
17
- }
18
- async reply(content) {
19
- if (this.client.cache.messages.has(this.message.id)) var existingMessage = this.client.cache.messages.get(this.message.id);
20
- if (!existingMessage) {
21
- const msg = await this.message.reply(content);
22
- this.message.response = msg.id;
23
- if (this.client.handlerOptions.message?.handleEdits || this.client.handlerOptions.message?.handleDeletes) {
24
- this.client.cache.messages.set(this.message.id, this.message);
25
- setInterval(() => {
26
- this.client.cache.messages.delete(this.message.id);
27
- }, this.client.settings.cooldown?.cache || 300000);
28
- }
29
- return msg;
30
- }
31
- if (existingMessage && this.client.handlerOptions.message?.handleEdits) {
32
- try {
33
- const msg = await this.message.channel.messages.fetch(existingMessage.response);
34
- msg.edit(content);
35
- return msg;
36
- } catch {
37
- const msg = await this.message.reply(content);
38
- this.message.response = msg.id;
39
- if (this.client.handlerOptions.message?.handleEdits || this.client.handlerOptions.message?.handleDeletes) {
40
- this.client.cache.messages.set(this.message.id, this.message);
41
- setInterval(() => {
42
- this.client.cache.messages.delete(this.message.id);
43
- }, this.client.settings.cooldown?.cache || 300000);
44
- }
45
- }
46
- }
47
- }
48
- async send(content) {
49
- if (this.client.cache.messages.has(this.message.id)) var existingMessage = this.client.cache.messages.get(this.message.id);
50
- if (!existingMessage) {
51
- const msg = await this.message.channel.send(content);
52
- this.message.response = msg.id;
53
- if (this.client.handlerOptions.message?.handleEdits || this.client.handlerOptions.message?.handleDeletes) {
54
- this.client.cache.messages.set(this.message.id, this.message);
55
- setInterval(() => {
56
- this.client.cache.messages.delete(this.message.id);
57
- }, this.client.settings.cooldown?.cache || 300000);
58
- }
59
- return msg;
60
- }
61
- if (existingMessage && this.client.handlerOptions.message?.handleEdits) {
62
- try {
63
- const msg = await this.message.channel.messages.fetch(existingMessage.response);
64
- msg.edit(content);
65
- return msg;
66
- } catch {
67
- const msg = await this.message.channel.send(content);
68
- this.message.response = msg.id;
69
- if (this.client.handlerOptions.message?.handleEdits || this.client.handlerOptions.message?.handleDeletes) {
70
- this.client.cache.messages.set(this.message.id, this.message);
71
- setInterval(() => {
72
- this.client.cache.messages.delete(this.message.id);
73
- }, this.client.settings.cooldown?.cache || 300000);
74
- }
75
- }
76
- }
77
- }
78
- async defer(time) {
79
- return new Promise((resolve) => setTimeout(resolve, time));
80
- }
81
- getCommands() {
82
- return this.client.commands.message;
83
- }
84
- getCommandName() {}
85
- selectMenuPaginator(embeds, options) {}
86
- buttonPaginator(embeds, options) {}
87
- buttonMenuPaginator(embeds, options) {}
88
- isOwner() {
89
- return this.client.util.isOwner(this.message.author.id);
90
- }
91
- createModal() {}
92
- }
93
- exports.MessageCommandUtil = MessageCommandUtil;
94
- class InteractionCommandUtil {
95
- client;
96
- interaction;
97
- constructor(client, interaction) {
98
- this.client = client;
99
- this.interaction = interaction;
100
- }
101
- reply(content) {
102
- return this.interaction.replied || this.interaction.deferred ? this.interaction.editReply(content) : this.interaction.reply(content);
103
- }
104
- async defer(time) {
105
- return new Promise((resolve) => setTimeout(resolve, time));
106
- }
107
- getCommands() {
108
- if (this.interaction.commandType === 1) return this.client.commands.slash;
109
- else return this.client.commands.context;
110
- }
111
- getCommandName() {}
112
- selectMenuPaginator(embeds, options) {
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 = [];
117
- if (!options.index) {
118
- options.index = new discord_js_1.EmbedBuilder().setTitle('Index').setColor('Random');
119
- for (const embed of embeds) {
120
- options.index.addFields([
121
- {
122
- name: embed.data.title || 'No Name',
123
- value: embed.data.description || 'Page',
124
- inline: embeds.length > 25 / 2 ? true : false,
125
- },
126
- ]);
127
- }
128
- }
129
- if (!options.row) {
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' });
138
- embeds.map((embed, i = 0) => {
139
- options?.component?.addOptions({
140
- label: embed.data.title || 'No Name',
141
- description: embed.data.description || `Page ${i}`,
142
- value: String(i + 1),
143
- });
144
- });
145
- options.row.addComponents(options.component);
146
- }
147
- embeds.unshift(options.index);
148
- const content = {
149
- embeds: [options.index],
150
- components: [options.row, ...options.components],
151
- ephemeral: !!options.ephemeral,
152
- };
153
- (options.reply === undefined || options.reply === true ? this.interaction.util.reply(content) : this.interaction.channel.send(content)).then(() => {
154
- const collector = this.interaction.channel
155
- .createMessageComponentCollector({
156
- filter: options?.filter,
157
- time: options?.time || 60000,
158
- })
159
- .on('collect', (interaction) => {
160
- if (!interaction.customId.startsWith(this.interaction.id)) return;
161
- interaction.update({
162
- embeds: [embeds[parseInt(interaction.values[0])]],
163
- });
164
- })
165
- .on('end', () => {
166
- this.interaction.editReply({ components: [] });
167
- });
168
- });
169
- }
170
- buttonPaginator(embeds, options) {
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 = [];
175
- if (!options.row) {
176
- options.row = new discord_js_1.ActionRowBuilder();
177
- if (!options.id) options.id = `${this.interaction.id}-menu`;
178
- }
179
- if (!options.buttons) options.buttons = ['⏮️', '◀️', '⏹️', '▶️', '⏭️'];
180
- for (const button of options.buttons) {
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
- );
187
- }
188
- let embed = embeds[options.index || 0];
189
- const content = {
190
- embeds: [embed],
191
- components: [options.row, ...options.components],
192
- ephemeral: !!options.ephemeral,
193
- };
194
- (options.reply === undefined || options.reply === true ? this.interaction.util.reply(content) : this.interaction.channel.send(content)).then((message) => {
195
- const collector = message.channel
196
- .createMessageComponentCollector({
197
- filter: options.filter,
198
- time: options?.time || 60000,
199
- })
200
- .on('collect', (interaction) => {
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
- }
225
- }
226
- stop
227
- ? interaction.update({
228
- embeds: [embed],
229
- components: [],
230
- })
231
- : interaction.update({
232
- embeds: [embed],
233
- });
234
- }
235
- })
236
- .on('end', () => {
237
- this.interaction.editReply({ components: [] });
238
- });
239
- });
240
- }
241
- buttonMenuPaginator(embeds, options) {}
242
- isOwner() {
243
- return this.client.util.isOwner(this.interaction.user.id);
244
- }
245
- createModal() {}
246
- }
247
- exports.InteractionCommandUtil = InteractionCommandUtil;
@@ -1,12 +0,0 @@
1
- import { Interaction } from 'discord.js';
2
- import ContextCommandBuilder from '../build/ContextCommandBuilder.js';
3
- import MessageCommandBuilder from '../build/MessageCommandBuilder.js';
4
- import SlashCommandBuilder from '../build/SlashCommandBuilder.js';
5
- import XernerxClient from '../client/XernerxClient.js';
6
- import { XernerxMessage } from '../types/types.js';
7
- export default function commandValidation(
8
- action: XernerxMessage | Interaction,
9
- command: SlashCommandBuilder | MessageCommandBuilder | ContextCommandBuilder | any,
10
- client: XernerxClient,
11
- res?: boolean
12
- ): boolean;
@@ -1,11 +0,0 @@
1
- import XernerxClient from '../client/XernerxClient.js';
2
- import { XernerxInteraction, XernerxMessage } from '../types/types.js';
3
- export declare class InhibitorValidation {
4
- client: XernerxClient;
5
- action: XernerxMessage | XernerxInteraction;
6
- command: string;
7
- inhibited: Record<string, string | void>;
8
- constructor(client: XernerxClient, action: XernerxMessage | XernerxInteraction, command: string);
9
- inhibit(): Promise<Record<string, string | void> | undefined>;
10
- private args;
11
- }
@@ -1,40 +0,0 @@
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 {
6
- client;
7
- action;
8
- command;
9
- inhibited;
10
- constructor(client, action, command) {
11
- this.client = client;
12
- this.action = action;
13
- this.command = command;
14
- this.inhibited = {};
15
- }
16
- async inhibit() {
17
- for (const inhibitor of this.client.inhibitors) {
18
- const inhibit = inhibitor[1];
19
- if (inhibit) this.inhibited[inhibit.name] = await inhibit.check(this.action, this.args(this.action, inhibit.type));
20
- }
21
- for (const inhibit of Object.values(this.inhibited)) {
22
- if (inhibit) return this.inhibited;
23
- }
24
- }
25
- args(action, type) {
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;
30
- // if (type === InhibitorType.Command)
31
- // return this.client.util.getAllCommands().filter(this.command.name);
32
- // if (type === InhibitorType.MessageCommand)
33
- // return this.client.util.getAllMessageCommands().find(this.command.name);
34
- // if (type === InhibitorType.SlashCommand)
35
- // return this.client.util.getAllSlashCommands().find(this.command.name);
36
- // if (type === InhibitorType.ContextCommand)
37
- // return this.client.util.getAllContextCommands().find(this.command.name);
38
- }
39
- }
40
- exports.InhibitorValidation = InhibitorValidation;
File without changes
File without changes
File without changes
File without changes