xernerx 3.6.0 → 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 (201) 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/{cjs/models → models}/CommandArguments.js +2 -7
  70. package/dist/{mjs/models → models}/Events.js +44 -56
  71. package/dist/models/Extensions.js +23 -0
  72. package/dist/models/XernerxUser.js +9 -0
  73. package/dist/tools/XernerxError.d.ts +6 -0
  74. package/dist/tools/XernerxError.js +10 -0
  75. package/dist/tools/XernerxLog.d.ts +13 -0
  76. package/dist/tools/XernerxLog.js +30 -0
  77. package/dist/tools/classes.d.ts +6 -0
  78. package/dist/tools/classes.js +10 -0
  79. package/dist/tools/loggers.d.ts +4 -0
  80. package/dist/tools/loggers.js +4 -0
  81. package/dist/{mjs/tools → tools}/package.d.ts +1 -0
  82. package/dist/{cjs/tools → tools}/package.js +4 -5
  83. package/dist/{cjs/types → types}/enums.js +8 -11
  84. package/dist/types/extenders.d.ts +23 -0
  85. package/dist/types/extenders.js +1 -0
  86. package/dist/types/interfaces.d.ts +224 -0
  87. package/dist/types/interfaces.js +1 -0
  88. package/dist/types/options.js +1 -0
  89. package/dist/types/types.d.ts +181 -0
  90. package/dist/types/types.js +1 -0
  91. package/dist/utils/ClientUtil.d.ts +6 -0
  92. package/dist/utils/ClientUtil.js +7 -0
  93. package/dist/{cjs/utils → utils}/CommandUtil.js +14 -29
  94. package/dist/utils/InteractionArguments.d.ts +1 -0
  95. package/dist/utils/InteractionArguments.js +1 -0
  96. package/dist/utils/InteractionUtil.d.ts +10 -0
  97. package/dist/utils/InteractionUtil.js +15 -0
  98. package/dist/utils/MessageUtil.d.ts +11 -0
  99. package/dist/utils/MessageUtil.js +42 -0
  100. package/dist/utils/Util.d.ts +5 -0
  101. package/dist/utils/Util.js +6 -0
  102. package/dist/{mjs/validators → validators}/CommandValidations.js +10 -13
  103. package/dist/validators/InhibitorValidations.d.ts +18 -0
  104. package/dist/validators/InhibitorValidations.js +34 -0
  105. package/dist/validators/commandValidation.d.ts +6 -0
  106. package/dist/validators/commandValidation.js +48 -0
  107. package/dist/validators/commands.d.ts +4 -0
  108. package/dist/validators/commands.js +25 -0
  109. package/package.json +10 -14
  110. package/dist/cjs/build/ContextCommandBuilder.d.ts +0 -63
  111. package/dist/cjs/build/ContextCommandBuilder.js +0 -97
  112. package/dist/cjs/build/EventBuilder.js +0 -44
  113. package/dist/cjs/build/InhibitorBuilder.js +0 -37
  114. package/dist/cjs/build/MessageCommandBuilder.js +0 -100
  115. package/dist/cjs/build/SlashCommandBuilder.js +0 -169
  116. package/dist/cjs/client/XernerxClient.d.ts +0 -29
  117. package/dist/cjs/client/XernerxClient.js +0 -120
  118. package/dist/cjs/handlers/CommandHandler.d.ts +0 -27
  119. package/dist/cjs/handlers/CommandHandler.js +0 -45
  120. package/dist/cjs/handlers/EventHandler.d.ts +0 -13
  121. package/dist/cjs/handlers/EventHandler.js +0 -19
  122. package/dist/cjs/handlers/Handler.d.ts +0 -57
  123. package/dist/cjs/handlers/Handler.js +0 -308
  124. package/dist/cjs/handlers/InhibitorHandler.d.ts +0 -18
  125. package/dist/cjs/handlers/InhibitorHandler.js +0 -24
  126. package/dist/cjs/handlers/WebhookHandler.d.ts +0 -7
  127. package/dist/cjs/handlers/WebhookHandler.js +0 -23
  128. package/dist/cjs/main.d.ts +0 -44
  129. package/dist/cjs/main.js +0 -112
  130. package/dist/cjs/models/Events.js +0 -309
  131. package/dist/cjs/models/Extensions.js +0 -26
  132. package/dist/cjs/models/XernerxUser.js +0 -12
  133. package/dist/cjs/tools/XernerxError.d.ts +0 -5
  134. package/dist/cjs/tools/XernerxError.js +0 -11
  135. package/dist/cjs/tools/package.d.ts +0 -44
  136. package/dist/cjs/types/interfaces.d.ts +0 -27
  137. package/dist/cjs/types/interfaces.js +0 -2
  138. package/dist/cjs/types/options.js +0 -2
  139. package/dist/cjs/types/types.d.ts +0 -62
  140. package/dist/cjs/types/types.js +0 -2
  141. package/dist/cjs/utils/ClientUtil.d.ts +0 -26
  142. package/dist/cjs/utils/ClientUtil.js +0 -211
  143. package/dist/cjs/validators/CommandValidations.js +0 -169
  144. package/dist/cjs/validators/InhibitorValidations.d.ts +0 -11
  145. package/dist/cjs/validators/InhibitorValidations.js +0 -40
  146. package/dist/mjs/build/ContextCommandBuilder.d.ts +0 -63
  147. package/dist/mjs/build/ContextCommandBuilder.js +0 -97
  148. package/dist/mjs/build/EventBuilder.js +0 -44
  149. package/dist/mjs/build/InhibitorBuilder.d.ts +0 -19
  150. package/dist/mjs/build/InhibitorBuilder.js +0 -37
  151. package/dist/mjs/build/MessageCommandBuilder.d.ts +0 -59
  152. package/dist/mjs/build/MessageCommandBuilder.js +0 -100
  153. package/dist/mjs/build/SlashCommandBuilder.d.ts +0 -65
  154. package/dist/mjs/build/SlashCommandBuilder.js +0 -169
  155. package/dist/mjs/client/XernerxClient.d.ts +0 -29
  156. package/dist/mjs/client/XernerxClient.js +0 -120
  157. package/dist/mjs/handlers/CommandHandler.d.ts +0 -27
  158. package/dist/mjs/handlers/CommandHandler.js +0 -45
  159. package/dist/mjs/handlers/EventHandler.d.ts +0 -13
  160. package/dist/mjs/handlers/EventHandler.js +0 -19
  161. package/dist/mjs/handlers/Handler.d.ts +0 -57
  162. package/dist/mjs/handlers/Handler.js +0 -308
  163. package/dist/mjs/handlers/InhibitorHandler.d.ts +0 -18
  164. package/dist/mjs/handlers/InhibitorHandler.js +0 -24
  165. package/dist/mjs/handlers/WebhookHandler.d.ts +0 -7
  166. package/dist/mjs/handlers/WebhookHandler.js +0 -23
  167. package/dist/mjs/main.d.ts +0 -44
  168. package/dist/mjs/main.js +0 -112
  169. package/dist/mjs/models/CommandArguments.d.ts +0 -17
  170. package/dist/mjs/models/CommandArguments.js +0 -106
  171. package/dist/mjs/models/Events.d.ts +0 -24
  172. package/dist/mjs/models/Extensions.d.ts +0 -7
  173. package/dist/mjs/models/Extensions.js +0 -26
  174. package/dist/mjs/models/XernerxUser.d.ts +0 -2
  175. package/dist/mjs/models/XernerxUser.js +0 -12
  176. package/dist/mjs/tools/XernerxError.d.ts +0 -5
  177. package/dist/mjs/tools/XernerxError.js +0 -11
  178. package/dist/mjs/tools/package.js +0 -45
  179. package/dist/mjs/types/enums.d.ts +0 -44
  180. package/dist/mjs/types/enums.js +0 -38
  181. package/dist/mjs/types/interfaces.d.ts +0 -27
  182. package/dist/mjs/types/interfaces.js +0 -2
  183. package/dist/mjs/types/options.d.ts +0 -254
  184. package/dist/mjs/types/options.js +0 -2
  185. package/dist/mjs/types/types.d.ts +0 -62
  186. package/dist/mjs/types/types.js +0 -2
  187. package/dist/mjs/utils/ClientUtil.d.ts +0 -26
  188. package/dist/mjs/utils/ClientUtil.js +0 -211
  189. package/dist/mjs/utils/CommandUtil.d.ts +0 -58
  190. package/dist/mjs/utils/CommandUtil.js +0 -247
  191. package/dist/mjs/validators/CommandValidations.d.ts +0 -12
  192. package/dist/mjs/validators/InhibitorValidations.d.ts +0 -11
  193. package/dist/mjs/validators/InhibitorValidations.js +0 -40
  194. /package/dist/{cjs/models → models}/CommandArguments.d.ts +0 -0
  195. /package/dist/{cjs/models → models}/Events.d.ts +0 -0
  196. /package/dist/{cjs/models → models}/Extensions.d.ts +0 -0
  197. /package/dist/{cjs/models → models}/XernerxUser.d.ts +0 -0
  198. /package/dist/{cjs/types → types}/enums.d.ts +0 -0
  199. /package/dist/{cjs/types → types}/options.d.ts +0 -0
  200. /package/dist/{cjs/utils → utils}/CommandUtil.d.ts +0 -0
  201. /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,169 +0,0 @@
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');
5
- function getUser(from) {
6
- if (from instanceof discord_js_1.Message) return from.author;
7
- else return from.user;
8
- }
9
- function commandValidation(action, command, client, res = false) {
10
- let user = getUser(action);
11
- if (client.settings.ignore?.owner && client.util.isOwner(user.id)) return res;
12
- else if (inCooldown(user, client, command, action)) return true;
13
- else if (command.owner && !client.util.isOwner(user.id)) {
14
- res = true;
15
- emit(client, action, command, 'Not an owner', client.settings.ownerId);
16
- } else if (command.channelType?.length > 0 || command.channelType) {
17
- if (!Array.isArray(command.channelType)) command.channelType = [command.channelType];
18
- if (!command?.channelType?.includes(action.channel?.type)) {
19
- res = true;
20
- emit(client, action, command, 'Not the correct channel', command.channelType);
21
- }
22
- } else if (command.channels?.length > 0 && !command.channels.includes(action.channel?.id)) {
23
- res = true;
24
- emit(client, action, command, 'Not a whitelisted channel', command.channels);
25
- } else if (command.guilds?.length > 0 && !command.guilds.includes(action.guild?.id)) {
26
- res = true;
27
- emit(client, action, command, 'Not a whitelisted guild', command.guilds);
28
- } else if (command.channelType && command.channelType !== action.channel?.type) {
29
- res = true;
30
- emit(client, action, command, 'Not the correct type of channel', command.channelType);
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 = [];
34
- if (Array.isArray(permissions))
35
- permissions.map((permission) => {
36
- if (!(action.member?.permissions).has(permission)) {
37
- missing.push(permission);
38
- }
39
- });
40
- if (missing.length > 0) {
41
- res = true;
42
- emit(client, action, command, 'Missing User Permissions', missing);
43
- }
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 = [];
47
- if (Array.isArray(permissions))
48
- permissions.map((permission) => {
49
- if (!(action.member?.permissions).has(permission)) {
50
- missing.push(permission);
51
- }
52
- });
53
- if (missing.length > 0) {
54
- res = true;
55
- emit(client, action, command, 'Missing Client Permissions', missing);
56
- }
57
- }
58
- return res;
59
- }
60
- exports.default = commandValidation;
61
- function emit(client, action, command, reason, extra) {
62
- return client.emit('commandBlock', action, command, reason, extra);
63
- }
64
- function inCooldown(user, client, command, action) {
65
- let res = false,
66
- downs = {};
67
- const { cooldowns, messageCommands, slashCommands, contextCommands, commands } = client.cache;
68
- if (command.commandType === enums_js_1.CommandType.MessageCommand && client.handlerOptions.message.cooldown) {
69
- if (messageCommands.has(user.id)) {
70
- const usr = messageCommands.get(user.id);
71
- usr.timeRemaining = usr.endsAt - Date.now();
72
- downs.message = usr;
73
- res = true;
74
- }
75
- if (!messageCommands.has(user.id)) {
76
- messageCommands.set(user.id, toCooldown(action, command, client.handlerOptions.message.cooldown, user.id));
77
- setInterval(() => {
78
- messageCommands.delete(user.id);
79
- }, client.handlerOptions.message.cooldown);
80
- }
81
- }
82
- if (command.commandType === enums_js_1.CommandType.SlashCommand && client.handlerOptions.slash.cooldown) {
83
- if (slashCommands.has(user.id)) {
84
- const usr = slashCommands.get(user.id);
85
- usr.timeRemaining = usr.endsAt - Date.now();
86
- downs.slash = usr;
87
- res = true;
88
- }
89
- if (!slashCommands.has(user.id)) {
90
- slashCommands.set(user.id, toCooldown(action, command, client.handlerOptions.slash.cooldown, user.id));
91
- setInterval(() => {
92
- slashCommands.delete(user.id);
93
- }, client.handlerOptions.slash.cooldown);
94
- }
95
- }
96
- if (command.commandType === enums_js_1.CommandType.ContextCommand && client.handlerOptions.context.cooldown) {
97
- if (contextCommands.has(user.id)) {
98
- const usr = contextCommands.get(user.id);
99
- usr.timeRemaining = usr.endsAt - Date.now();
100
- downs.context = usr;
101
- res = true;
102
- }
103
- if (!contextCommands.has(user.id)) {
104
- contextCommands.set(user.id, toCooldown(action, command, client.handlerOptions.context.cooldown, user.id));
105
- setInterval(() => {
106
- contextCommands.delete(user.id);
107
- }, client.handlerOptions.context.cooldown);
108
- }
109
- }
110
- if (client.settings?.cooldown?.default) {
111
- if (cooldowns.has(user.id)) {
112
- const usr = cooldowns.get(user.id);
113
- usr.timeRemaining = usr.endsAt - Date.now();
114
- downs.default = usr;
115
- res = true;
116
- }
117
- if (!cooldowns.has(user.id)) {
118
- cooldowns.set(user.id, toCooldown(action, command, client.settings.cooldown.default, user.id));
119
- setInterval(() => {
120
- cooldowns.delete(user.id);
121
- }, client.settings.cooldown.default);
122
- }
123
- }
124
- if (command.cooldown) {
125
- const name = user.id + '-' + (command.data?.name || command?.name) + '-' + command.commandType;
126
- if (commands.has(name)) {
127
- const usr = commands.get(name);
128
- usr.timeRemaining = usr.endsAt - Date.now();
129
- downs.command = usr;
130
- res = true;
131
- }
132
- if (!commands.has(name)) {
133
- commands.set(name, toCooldown(action, command, command.cooldown, name));
134
- setInterval(() => {
135
- commands.delete(name);
136
- }, command.cooldown);
137
- }
138
- }
139
- if (Object.keys(downs).length > 0) client.emit('commandCooldown', action, command, downs);
140
- return res;
141
- }
142
- function toCooldown(action, command, cooldown, name) {
143
- let user = getUser(action);
144
- return {
145
- name,
146
- id: user.id,
147
- tag: user.tag,
148
- commandType: command.commandType,
149
- commandName: command?.data?.name || command?.name,
150
- guildId: action?.guild?.id,
151
- channelId: action?.channel?.id,
152
- startsAt: Number(Date.now()),
153
- endsAt: Number(Date.now()) + cooldown,
154
- };
155
- }
156
- function handlerPermissions(client, commandType, type) {
157
- let permissions = [];
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 || [];
167
- }
168
- return permissions;
169
- }
@@ -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;
@@ -1,63 +0,0 @@
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
- }
@@ -1,97 +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
- 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;
@@ -1,44 +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
- const zod_1 = require('zod');
9
- const XernerxClient_js_1 = __importDefault(require('../client/XernerxClient.js'));
10
- /**
11
- * @description - The event builder for events.
12
- * @param {String} id - The unique ID of the event.
13
- * @param {EventOptions} options - The event options.
14
- */
15
- class EventBuilder {
16
- id;
17
- name;
18
- emitter;
19
- type;
20
- once;
21
- client;
22
- constructor(id, options) {
23
- this.id = id;
24
- zod_1.z
25
- .object({
26
- name: zod_1.z.string(),
27
- emitter: zod_1.z.string().optional(),
28
- type: zod_1.z.string().optional(),
29
- once: zod_1.z.boolean().optional(),
30
- })
31
- .parse(options);
32
- this.name = options.name;
33
- this.emitter = options.emitter || 'client';
34
- this.type = options.type || 'discord';
35
- this.once = options.once || false;
36
- this.client = XernerxClient_js_1.default;
37
- }
38
- /**
39
- * @description run your custom event here.
40
- * TODO - update description
41
- */
42
- async run() {}
43
- }
44
- exports.default = EventBuilder;
@@ -1,19 +0,0 @@
1
- import XernerxClient from '../client/XernerxClient.js';
2
- import { InhibitorOptions, MessageArgumentOptions, SlashArgumentOptions } from '../types/options.js';
3
- import { XernerxInteraction, XernerxMessage } from '../types/types.js';
4
- /**
5
- * @description - The inhibitor builder for inhibitors.
6
- * @param {String} id - The unique ID of the inhibitor.
7
- * @param {InhibitorOptions} options - The inhibitor options.
8
- */
9
- export default class InhibitorBuilder {
10
- id: string;
11
- name: string;
12
- type: import('../main.js').InhibitorType;
13
- client: typeof XernerxClient;
14
- constructor(id: string, options: InhibitorOptions);
15
- /**
16
- * TODO - update description
17
- */
18
- check(interaction: XernerxInteraction | XernerxMessage, args: SlashArgumentOptions | MessageArgumentOptions): Promise<void>;
19
- }