seyfert 2.1.0 → 2.1.1-dev-11316886063.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 (241) hide show
  1. package/lib/api/Router.d.ts +2 -2
  2. package/lib/api/Router.js +2 -1
  3. package/lib/api/Routes/applications.d.ts +29 -30
  4. package/lib/api/Routes/cdn.d.ts +6 -1
  5. package/lib/api/Routes/channels.d.ts +44 -45
  6. package/lib/api/Routes/gateway.d.ts +3 -4
  7. package/lib/api/Routes/guilds.d.ts +81 -80
  8. package/lib/api/Routes/index.d.ts +3 -1
  9. package/lib/api/Routes/interactions.d.ts +6 -6
  10. package/lib/api/Routes/invites.d.ts +3 -4
  11. package/lib/api/Routes/skus.d.ts +4 -5
  12. package/lib/api/Routes/soundboard.d.ts +23 -0
  13. package/lib/api/Routes/soundboard.js +2 -0
  14. package/lib/api/Routes/stage-instances.d.ts +5 -6
  15. package/lib/api/Routes/stickers.d.ts +3 -4
  16. package/lib/api/Routes/users.d.ts +11 -12
  17. package/lib/api/Routes/voice.d.ts +2 -3
  18. package/lib/api/Routes/webhooks.d.ts +16 -15
  19. package/lib/api/api.d.ts +17 -11
  20. package/lib/api/api.js +12 -10
  21. package/lib/api/shared.d.ts +1 -1
  22. package/lib/api/utils/constants.d.ts +2 -0
  23. package/lib/api/utils/constants.js +2 -1
  24. package/lib/builders/ActionRow.d.ts +1 -1
  25. package/lib/builders/Attachment.d.ts +2 -2
  26. package/lib/builders/Attachment.js +1 -1
  27. package/lib/builders/Button.d.ts +1 -1
  28. package/lib/builders/Button.js +1 -1
  29. package/lib/builders/Embed.d.ts +1 -1
  30. package/lib/builders/Embed.js +2 -2
  31. package/lib/builders/Modal.d.ts +1 -1
  32. package/lib/builders/Poll.d.ts +1 -1
  33. package/lib/builders/Poll.js +1 -1
  34. package/lib/builders/SelectMenu.d.ts +1 -1
  35. package/lib/builders/SelectMenu.js +1 -1
  36. package/lib/builders/types.d.ts +2 -1
  37. package/lib/cache/adapters/default.js +5 -3
  38. package/lib/cache/adapters/limited.d.ts +1 -2
  39. package/lib/cache/adapters/limited.js +34 -30
  40. package/lib/cache/adapters/workeradapter.js +3 -1
  41. package/lib/cache/index.d.ts +8 -11
  42. package/lib/cache/index.js +38 -37
  43. package/lib/cache/resources/bans.d.ts +2 -2
  44. package/lib/cache/resources/bans.js +1 -1
  45. package/lib/cache/resources/channels.d.ts +1 -1
  46. package/lib/cache/resources/default/guild-related.d.ts +1 -2
  47. package/lib/cache/resources/emojis.d.ts +2 -2
  48. package/lib/cache/resources/emojis.js +1 -1
  49. package/lib/cache/resources/guilds.d.ts +2 -2
  50. package/lib/cache/resources/guilds.js +7 -11
  51. package/lib/cache/resources/members.d.ts +2 -2
  52. package/lib/cache/resources/members.js +1 -1
  53. package/lib/cache/resources/messages.d.ts +2 -2
  54. package/lib/cache/resources/messages.js +3 -3
  55. package/lib/cache/resources/overwrites.d.ts +1 -1
  56. package/lib/cache/resources/roles.d.ts +2 -2
  57. package/lib/cache/resources/roles.js +1 -1
  58. package/lib/cache/resources/stickers.d.ts +2 -2
  59. package/lib/cache/resources/stickers.js +1 -1
  60. package/lib/cache/resources/users.d.ts +2 -2
  61. package/lib/cache/resources/users.js +1 -1
  62. package/lib/cache/resources/voice-states.d.ts +2 -2
  63. package/lib/cache/resources/voice-states.js +1 -1
  64. package/lib/client/base.d.ts +9 -14
  65. package/lib/client/base.js +43 -44
  66. package/lib/client/client.d.ts +3 -7
  67. package/lib/client/client.js +24 -41
  68. package/lib/client/collectors.js +1 -1
  69. package/lib/client/httpclient.d.ts +1 -1
  70. package/lib/client/transformers.d.ts +37 -34
  71. package/lib/client/transformers.js +66 -63
  72. package/lib/client/workerclient.d.ts +10 -11
  73. package/lib/client/workerclient.js +180 -75
  74. package/lib/collection.d.ts +3 -3
  75. package/lib/commands/applications/chat.d.ts +12 -32
  76. package/lib/commands/applications/chat.js +5 -6
  77. package/lib/commands/applications/chatcontext.d.ts +6 -6
  78. package/lib/commands/applications/chatcontext.js +16 -8
  79. package/lib/commands/applications/entryPoint.d.ts +1 -1
  80. package/lib/commands/applications/entrycontext.d.ts +6 -6
  81. package/lib/commands/applications/entrycontext.js +4 -4
  82. package/lib/commands/applications/menu.d.ts +1 -1
  83. package/lib/commands/applications/menucontext.d.ts +5 -5
  84. package/lib/commands/applications/menucontext.js +6 -6
  85. package/lib/commands/applications/options.d.ts +104 -28
  86. package/lib/commands/applications/options.js +4 -4
  87. package/lib/commands/applications/shared.d.ts +5 -2
  88. package/lib/commands/basecontext.d.ts +1 -1
  89. package/lib/commands/decorators.d.ts +10 -10
  90. package/lib/commands/decorators.js +5 -4
  91. package/lib/commands/handle.d.ts +9 -9
  92. package/lib/commands/handle.js +94 -68
  93. package/lib/commands/handler.d.ts +5 -5
  94. package/lib/commands/handler.js +21 -17
  95. package/lib/commands/optionresolver.d.ts +4 -4
  96. package/lib/commands/optionresolver.js +3 -3
  97. package/lib/common/it/formatter.d.ts +21 -21
  98. package/lib/common/it/formatter.js +40 -41
  99. package/lib/common/it/logger.js +1 -1
  100. package/lib/common/it/utils.d.ts +4 -3
  101. package/lib/common/it/utils.js +52 -27
  102. package/lib/common/shorters/application.d.ts +2 -3
  103. package/lib/common/shorters/application.js +3 -3
  104. package/lib/common/shorters/bans.js +1 -1
  105. package/lib/common/shorters/channels.d.ts +3 -3
  106. package/lib/common/shorters/channels.js +3 -3
  107. package/lib/common/shorters/emojis.js +4 -4
  108. package/lib/common/shorters/guilds.d.ts +3 -3
  109. package/lib/common/shorters/guilds.js +5 -9
  110. package/lib/common/shorters/interaction.d.ts +3 -3
  111. package/lib/common/shorters/interaction.js +6 -5
  112. package/lib/common/shorters/members.d.ts +4 -5
  113. package/lib/common/shorters/members.js +6 -7
  114. package/lib/common/shorters/messages.d.ts +1 -1
  115. package/lib/common/shorters/messages.js +4 -4
  116. package/lib/common/shorters/reactions.d.ts +1 -1
  117. package/lib/common/shorters/reactions.js +1 -1
  118. package/lib/common/shorters/roles.js +1 -1
  119. package/lib/common/shorters/templates.js +2 -2
  120. package/lib/common/shorters/threads.d.ts +1 -1
  121. package/lib/common/shorters/threads.js +17 -11
  122. package/lib/common/shorters/webhook.d.ts +1 -1
  123. package/lib/common/shorters/webhook.js +4 -4
  124. package/lib/common/types/options.d.ts +2 -2
  125. package/lib/common/types/resolvables.d.ts +1 -1
  126. package/lib/common/types/util.d.ts +4 -1
  127. package/lib/common/types/write.d.ts +1 -1
  128. package/lib/components/BaseComponent.js +1 -1
  129. package/lib/components/ButtonComponent.d.ts +1 -1
  130. package/lib/components/componentcommand.d.ts +1 -1
  131. package/lib/components/componentcontext.d.ts +4 -4
  132. package/lib/components/componentcontext.js +1 -1
  133. package/lib/components/handler.d.ts +10 -8
  134. package/lib/components/handler.js +16 -13
  135. package/lib/components/index.js +2 -1
  136. package/lib/components/modalcontext.d.ts +2 -2
  137. package/lib/components/modalcontext.js +1 -1
  138. package/lib/deps/mixer.d.ts +1 -1
  139. package/lib/events/handler.d.ts +5 -5
  140. package/lib/events/handler.js +66 -16
  141. package/lib/events/hooks/application_command.d.ts +1 -1
  142. package/lib/events/hooks/auto_moderation.d.ts +1 -1
  143. package/lib/events/hooks/auto_moderation.js +1 -1
  144. package/lib/events/hooks/channel.d.ts +1 -1
  145. package/lib/events/hooks/dispatch.d.ts +1 -1
  146. package/lib/events/hooks/entitlement.d.ts +4 -5
  147. package/lib/events/hooks/entitlement.js +4 -4
  148. package/lib/events/hooks/guild.d.ts +3 -3
  149. package/lib/events/hooks/guild.js +1 -1
  150. package/lib/events/hooks/index.d.ts +1 -0
  151. package/lib/events/hooks/index.js +1 -0
  152. package/lib/events/hooks/integration.d.ts +1 -1
  153. package/lib/events/hooks/integration.js +1 -1
  154. package/lib/events/hooks/interactions.d.ts +3 -3
  155. package/lib/events/hooks/invite.d.ts +1 -1
  156. package/lib/events/hooks/message.d.ts +3 -3
  157. package/lib/events/hooks/message.js +1 -1
  158. package/lib/events/hooks/presence.d.ts +2 -2
  159. package/lib/events/hooks/soundboard.d.ts +155 -0
  160. package/lib/events/hooks/soundboard.js +28 -0
  161. package/lib/events/hooks/stage.d.ts +2 -2
  162. package/lib/events/hooks/thread.d.ts +2 -2
  163. package/lib/events/hooks/thread.js +2 -2
  164. package/lib/events/hooks/typing.d.ts +1 -1
  165. package/lib/events/hooks/typing.js +1 -1
  166. package/lib/events/hooks/user.d.ts +2 -2
  167. package/lib/events/hooks/voice.d.ts +2 -2
  168. package/lib/events/hooks/voice.js +1 -1
  169. package/lib/events/hooks/webhook.d.ts +1 -1
  170. package/lib/index.d.ts +2 -2
  171. package/lib/index.js +3 -5
  172. package/lib/langs/handler.d.ts +2 -2
  173. package/lib/structures/Guild.d.ts +7 -4
  174. package/lib/structures/Guild.js +1 -1
  175. package/lib/structures/GuildBan.d.ts +1 -1
  176. package/lib/structures/GuildMember.d.ts +7 -5
  177. package/lib/structures/GuildMember.js +5 -3
  178. package/lib/structures/GuildRole.d.ts +1 -1
  179. package/lib/structures/GuildTemplate.d.ts +1 -1
  180. package/lib/structures/Interaction.d.ts +17 -14
  181. package/lib/structures/Interaction.js +28 -21
  182. package/lib/structures/Message.d.ts +4 -7
  183. package/lib/structures/Message.js +5 -5
  184. package/lib/structures/Poll.d.ts +3 -3
  185. package/lib/structures/Sticker.d.ts +2 -2
  186. package/lib/structures/Sticker.js +1 -1
  187. package/lib/structures/VoiceState.d.ts +2 -1
  188. package/lib/structures/VoiceState.js +1 -1
  189. package/lib/structures/Webhook.d.ts +3 -3
  190. package/lib/structures/Webhook.js +1 -1
  191. package/lib/structures/channels.d.ts +4 -4
  192. package/lib/structures/channels.js +6 -5
  193. package/lib/structures/extra/BitField.d.ts +3 -3
  194. package/lib/structures/extra/BitField.js +34 -33
  195. package/lib/structures/extra/DiscordBase.js +1 -1
  196. package/lib/structures/extra/Permissions.d.ts +2 -0
  197. package/lib/structures/extra/Permissions.js +21 -0
  198. package/lib/types/gateway.d.ts +53 -5
  199. package/lib/types/payloads/_interactions/base.d.ts +1 -1
  200. package/lib/types/payloads/channel.d.ts +2 -2
  201. package/lib/types/payloads/guild.d.ts +9 -1
  202. package/lib/types/payloads/guild.js +8 -0
  203. package/lib/types/payloads/index.d.ts +1 -0
  204. package/lib/types/payloads/index.js +1 -0
  205. package/lib/types/payloads/soundboard.d.ts +23 -0
  206. package/lib/types/payloads/soundboard.js +5 -0
  207. package/lib/types/payloads/user.js +0 -1
  208. package/lib/types/rest/application.d.ts +3 -3
  209. package/lib/types/rest/auditLog.d.ts +1 -1
  210. package/lib/types/rest/channel.d.ts +2 -2
  211. package/lib/types/rest/guild.d.ts +2 -2
  212. package/lib/types/rest/guildScheduledEvent.d.ts +1 -1
  213. package/lib/types/rest/index.d.ts +1 -0
  214. package/lib/types/rest/index.js +1 -0
  215. package/lib/types/rest/oauth2.d.ts +1 -1
  216. package/lib/types/rest/poll.d.ts +1 -1
  217. package/lib/types/rest/soundboard.d.ts +64 -0
  218. package/lib/types/rest/soundboard.js +2 -0
  219. package/lib/types/rest/stageInstance.d.ts +1 -1
  220. package/lib/types/rest/template.d.ts +1 -1
  221. package/lib/types/rest/user.d.ts +1 -1
  222. package/lib/types/rest/webhook.d.ts +1 -1
  223. package/lib/types/utils/index.d.ts +11 -2
  224. package/lib/types/utils/index.js +10 -2
  225. package/lib/websocket/SharedTypes.d.ts +11 -2
  226. package/lib/websocket/constants/index.js +0 -10
  227. package/lib/websocket/discord/basesocket.d.ts +1 -1
  228. package/lib/websocket/discord/shard.d.ts +1 -1
  229. package/lib/websocket/discord/shard.js +25 -16
  230. package/lib/websocket/discord/sharder.d.ts +9 -6
  231. package/lib/websocket/discord/sharder.js +91 -74
  232. package/lib/websocket/discord/shared.d.ts +3 -14
  233. package/lib/websocket/discord/socket/custom.js +19 -6
  234. package/lib/websocket/discord/worker.d.ts +8 -2
  235. package/lib/websocket/discord/workermanager.d.ts +42 -17
  236. package/lib/websocket/discord/workermanager.js +144 -37
  237. package/lib/websocket/structures/timeout.d.ts +4 -5
  238. package/lib/websocket/structures/timeout.js +23 -24
  239. package/package.json +72 -70
  240. package/lib/cache/resources/threads.d.ts +0 -14
  241. package/lib/cache/resources/threads.js +0 -32
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HandleCommand = void 0;
4
- const types_1 = require("../types");
5
4
  const _1 = require(".");
6
- const structures_1 = require("../structures");
7
- const components_1 = require("../components");
8
5
  const transformers_1 = require("../client/transformers");
6
+ const components_1 = require("../components");
7
+ const structures_1 = require("../structures");
8
+ const types_1 = require("../types");
9
9
  class HandleCommand {
10
10
  client;
11
11
  constructor(client) {
@@ -40,7 +40,7 @@ class HandleCommand {
40
40
  return this.contextMenuUser(command, interaction, context);
41
41
  }
42
42
  async contextMenuUser(command, interaction, context) {
43
- if (command.botPermissions && interaction.appPermissions) {
43
+ if (context.guildId && command.botPermissions && interaction.appPermissions) {
44
44
  const permissions = this.checkPermissions(interaction.appPermissions, command.botPermissions);
45
45
  if (permissions)
46
46
  return command.onBotPermissionsFail(context, permissions);
@@ -71,10 +71,10 @@ class HandleCommand {
71
71
  }
72
72
  }
73
73
  async entryPoint(command, interaction, context) {
74
- if (command.botPermissions && interaction.appPermissions) {
74
+ if (context.guildId && command.botPermissions && interaction.appPermissions) {
75
75
  const permissions = this.checkPermissions(interaction.appPermissions, command.botPermissions);
76
76
  if (permissions)
77
- return command.onBotPermissionsFail?.(context, permissions);
77
+ return command.onBotPermissionsFail(context, permissions);
78
78
  }
79
79
  const resultGlobal = await this.runGlobalMiddlewares(command, context);
80
80
  if (typeof resultGlobal === 'boolean')
@@ -102,10 +102,17 @@ class HandleCommand {
102
102
  }
103
103
  }
104
104
  async chatInput(command, interaction, resolver, context) {
105
- if (command.botPermissions && interaction.appPermissions) {
106
- const permissions = this.checkPermissions(interaction.appPermissions, command.botPermissions);
107
- if (permissions)
108
- return command.onBotPermissionsFail?.(context, permissions);
105
+ if (context.guildId && interaction.appPermissions) {
106
+ if (command.botPermissions) {
107
+ const permissions = this.checkPermissions(interaction.appPermissions, command.botPermissions);
108
+ if (permissions)
109
+ return command.onBotPermissionsFail?.(context, permissions);
110
+ }
111
+ if (command.defaultMemberPermissions) {
112
+ const permissions = this.checkPermissions(interaction.member.permissions, command.defaultMemberPermissions);
113
+ if (permissions)
114
+ return command.onPermissionsFail?.(context, permissions);
115
+ }
109
116
  }
110
117
  if (!(await this.runOptions(command, context, resolver)))
111
118
  return;
@@ -164,8 +171,9 @@ class HandleCommand {
164
171
  const data = this.makeMenuCommand(body, shardId, __reply);
165
172
  if (!data)
166
173
  return;
174
+ this.contextMenuMessage(data.command,
167
175
  // @ts-expect-error
168
- this.contextMenuMessage(data.command, data.interaction, data.context);
176
+ data.interaction, data.context);
169
177
  break;
170
178
  }
171
179
  case types_1.ApplicationCommandType.User: {
@@ -285,7 +293,7 @@ class HandleCommand {
285
293
  if (command.botPermissions) {
286
294
  const appPermissions = await self.members.permissions(rawMessage.guild_id, self.botId);
287
295
  const permissions = this.checkPermissions(appPermissions, command.botPermissions);
288
- if (!appPermissions.has('Administrator') && permissions) {
296
+ if (permissions) {
289
297
  return command.onBotPermissionsFail?.(context, permissions);
290
298
  }
291
299
  }
@@ -311,7 +319,9 @@ class HandleCommand {
311
319
  try {
312
320
  await command.onInternalError?.(this.client, command, error);
313
321
  }
314
- catch { }
322
+ catch {
323
+ // http 418
324
+ }
315
325
  }
316
326
  }
317
327
  argsParser(content, _command, _message) {
@@ -387,34 +397,36 @@ class HandleCommand {
387
397
  });
388
398
  }
389
399
  checkPermissions(app, bot) {
400
+ if (app.has('Administrator'))
401
+ return;
390
402
  const permissions = app.missings(...app.values([bot]));
391
- if (!app.has('Administrator') && permissions.length) {
403
+ if (permissions.length) {
392
404
  return app.keys(permissions);
393
405
  }
394
406
  return;
395
407
  }
396
- async fetchChannel(_option, query) {
408
+ fetchChannel(_option, query) {
397
409
  const id = query.match(/[0-9]{17,19}/g)?.[0];
398
410
  if (id)
399
411
  return this.client.channels.raw(id);
400
412
  return null;
401
413
  }
402
- async fetchUser(_option, query) {
414
+ fetchUser(_option, query) {
403
415
  const id = query.match(/[0-9]{17,19}/g)?.[0];
404
416
  if (id)
405
417
  return this.client.users.raw(id);
406
418
  return null;
407
419
  }
408
- async fetchMember(_option, query, guildId) {
420
+ fetchMember(_option, query, guildId) {
409
421
  const id = query.match(/[0-9]{17,19}/g)?.[0];
410
422
  if (id)
411
423
  return this.client.members.raw(guildId, id);
412
424
  return null;
413
425
  }
414
- async fetchRole(_option, query, guildId) {
426
+ fetchRole(_option, query, guildId) {
415
427
  const id = query.match(/[0-9]{17,19}/g)?.[0];
416
428
  if (id && guildId)
417
- return (await this.client.roles.listRaw(guildId)).find(x => x.id === id);
429
+ return this.client.roles.raw(guildId, id);
418
430
  return null;
419
431
  }
420
432
  async runGlobalMiddlewares(command, context) {
@@ -433,7 +445,9 @@ class HandleCommand {
433
445
  try {
434
446
  await command.onInternalError?.(this.client, command, e);
435
447
  }
436
- catch { }
448
+ catch {
449
+ // http 418
450
+ }
437
451
  }
438
452
  return false;
439
453
  }
@@ -453,7 +467,9 @@ class HandleCommand {
453
467
  try {
454
468
  await command.onInternalError?.(this.client, command, e);
455
469
  }
456
- catch { }
470
+ catch {
471
+ // http 418
472
+ }
457
473
  }
458
474
  return false;
459
475
  }
@@ -478,7 +494,9 @@ class HandleCommand {
478
494
  try {
479
495
  await command.onInternalError?.(this.client, command, e);
480
496
  }
481
- catch { }
497
+ catch {
498
+ // http 418
499
+ }
482
500
  }
483
501
  return false;
484
502
  }
@@ -513,13 +531,14 @@ class HandleCommand {
513
531
  if (channel) {
514
532
  if ('channel_types' in i) {
515
533
  if (!i.channel_types.includes(channel.type)) {
516
- errors.push({
517
- name: i.name,
518
- error: `The entered channel type is not one of ${i
519
- .channel_types.map(t => types_1.ChannelType[t])
520
- .join(', ')}`,
521
- fullError: ['CHANNEL_TYPES', i.channel_types],
522
- });
534
+ if (i.required)
535
+ errors.push({
536
+ name: i.name,
537
+ error: `The entered channel type is not one of ${i
538
+ .channel_types.map(t => types_1.ChannelType[t])
539
+ .join(', ')}`,
540
+ fullError: ['CHANNEL_TYPES', i.channel_types],
541
+ });
523
542
  break;
524
543
  }
525
544
  }
@@ -601,22 +620,24 @@ class HandleCommand {
601
620
  if (option.min_length) {
602
621
  if (value.length < option.min_length) {
603
622
  value = undefined;
604
- errors.push({
605
- name: i.name,
606
- error: `The entered string has less than ${option.min_length} characters. The minimum required is ${option.min_length} characters.`,
607
- fullError: ['STRING_MIN_LENGTH', option.min_length],
608
- });
623
+ if (i.required)
624
+ errors.push({
625
+ name: i.name,
626
+ error: `The entered string has less than ${option.min_length} characters. The minimum required is ${option.min_length} characters.`,
627
+ fullError: ['STRING_MIN_LENGTH', option.min_length],
628
+ });
609
629
  break;
610
630
  }
611
631
  }
612
632
  if (option.max_length) {
613
633
  if (value.length > option.max_length) {
614
634
  value = undefined;
615
- errors.push({
616
- name: i.name,
617
- error: `The entered string has more than ${option.max_length} characters. The maximum required is ${option.max_length} characters.`,
618
- fullError: ['STRING_MAX_LENGTH', option.max_length],
619
- });
635
+ if (i.required)
636
+ errors.push({
637
+ name: i.name,
638
+ error: `The entered string has more than ${option.max_length} characters. The maximum required is ${option.max_length} characters.`,
639
+ fullError: ['STRING_MAX_LENGTH', option.max_length],
640
+ });
620
641
  break;
621
642
  }
622
643
  }
@@ -624,13 +645,14 @@ class HandleCommand {
624
645
  const choice = option.choices.find(x => x.name === value);
625
646
  if (!choice) {
626
647
  value = undefined;
627
- errors.push({
628
- name: i.name,
629
- error: `The entered choice is invalid. Please choose one of the following options: ${option.choices
630
- .map(x => x.name)
631
- .join(', ')}.`,
632
- fullError: ['STRING_INVALID_CHOICE', option.choices],
633
- });
648
+ if (i.required)
649
+ errors.push({
650
+ name: i.name,
651
+ error: `The entered choice is invalid. Please choose one of the following options: ${option.choices
652
+ .map(x => x.name)
653
+ .join(', ')}.`,
654
+ fullError: ['STRING_INVALID_CHOICE', option.choices],
655
+ });
634
656
  break;
635
657
  }
636
658
  value = choice.value;
@@ -649,32 +671,35 @@ class HandleCommand {
649
671
  }
650
672
  if (Number.isNaN(value)) {
651
673
  value = undefined;
652
- errors.push({
653
- name: i.name,
654
- error: 'The entered choice is an invalid number.',
655
- fullError: ['NUMBER_NAN', args[i.name]],
656
- });
674
+ if (i.required)
675
+ errors.push({
676
+ name: i.name,
677
+ error: 'The entered choice is an invalid number.',
678
+ fullError: ['NUMBER_NAN', args[i.name]],
679
+ });
657
680
  break;
658
681
  }
659
682
  if (option.min_value) {
660
683
  if (value < option.min_value) {
661
684
  value = undefined;
662
- errors.push({
663
- name: i.name,
664
- error: `The entered number is less than ${option.min_value}. The minimum allowed is ${option.min_value}`,
665
- fullError: ['NUMBER_MIN_VALUE', option.min_value],
666
- });
685
+ if (i.required)
686
+ errors.push({
687
+ name: i.name,
688
+ error: `The entered number is less than ${option.min_value}. The minimum allowed is ${option.min_value}`,
689
+ fullError: ['NUMBER_MIN_VALUE', option.min_value],
690
+ });
667
691
  break;
668
692
  }
669
693
  }
670
694
  if (option.max_value) {
671
695
  if (value > option.max_value) {
672
696
  value = undefined;
673
- errors.push({
674
- name: i.name,
675
- error: `The entered number is greater than ${option.max_value}. The maximum allowed is ${option.max_value}`,
676
- fullError: ['NUMBER_MAX_VALUE', option.max_value],
677
- });
697
+ if (i.required)
698
+ errors.push({
699
+ name: i.name,
700
+ error: `The entered number is greater than ${option.max_value}. The maximum allowed is ${option.max_value}`,
701
+ fullError: ['NUMBER_MAX_VALUE', option.max_value],
702
+ });
678
703
  break;
679
704
  }
680
705
  }
@@ -683,13 +708,14 @@ class HandleCommand {
683
708
  const choice = option.choices.find(x => x.name === args[i.name]);
684
709
  if (!choice) {
685
710
  value = undefined;
686
- errors.push({
687
- name: i.name,
688
- error: `The entered choice is invalid. Please choose one of the following options: ${option.choices
689
- .map(x => x.name)
690
- .join(', ')}.`,
691
- fullError: ['NUMBER_INVALID_CHOICE', option.choices],
692
- });
711
+ if (i.required)
712
+ errors.push({
713
+ name: i.name,
714
+ error: `The entered choice is invalid. Please choose one of the following options: ${option.choices
715
+ .map(x => x.name)
716
+ .join(', ')}.`,
717
+ fullError: ['NUMBER_INVALID_CHOICE', option.choices],
718
+ });
693
719
  break;
694
720
  }
695
721
  value = choice.value;
@@ -1,25 +1,25 @@
1
- import { type APIApplicationCommandOption, type LocalizationMap } from '../types';
1
+ import type { EntryPointCommand } from '.';
2
2
  import type { Logger, MakeRequired, NulleableCoalising, OmitInsert } from '../common';
3
3
  import { BaseHandler } from '../common';
4
+ import { type APIApplicationCommandOption, type LocalizationMap } from '../types';
4
5
  import { Command, type CommandOption, SubCommand } from './applications/chat';
5
6
  import { ContextMenuCommand } from './applications/menu';
6
7
  import type { UsingClient } from './applications/shared';
7
- import type { EntryPointCommand } from '.';
8
8
  export declare class CommandHandler extends BaseHandler {
9
9
  protected logger: Logger;
10
10
  protected client: UsingClient;
11
11
  values: (Command | ContextMenuCommand)[];
12
12
  entryPoint: EntryPointCommand | null;
13
- protected filter: (path: string) => boolean;
13
+ filter: (path: string) => boolean;
14
14
  constructor(logger: Logger, client: UsingClient);
15
15
  reload(resolve: string | Command): Promise<void>;
16
16
  reloadAll(stopIfFail?: boolean): Promise<void>;
17
17
  protected shouldUploadLocales(locales?: LocalizationMap | null, cachedLocales?: LocalizationMap | null): boolean;
18
- protected shouldUploadOption(option: APIApplicationCommandOption, cached: APIApplicationCommandOption): boolean | undefined;
18
+ protected shouldUploadOption(option: APIApplicationCommandOption, cached: APIApplicationCommandOption): boolean;
19
19
  shouldUpload(file: string, guildId?: string): Promise<boolean>;
20
20
  set(commands: SeteableCommand[]): void;
21
21
  load(commandsDir: string, client: UsingClient): Promise<(Command | ContextMenuCommand)[]>;
22
- parseLocales(command: InstanceType<HandleableCommand>): Command | ContextMenuCommand | EntryPointCommand | SubCommand;
22
+ parseLocales(command: InstanceType<HandleableCommand>): Command | ContextMenuCommand | SubCommand | EntryPointCommand;
23
23
  parseGlobalLocales(command: InstanceType<HandleableCommand>): void;
24
24
  parseCommandOptionLocales(option: MakeRequired<CommandOption, 'locales'>): void;
25
25
  parseCommandLocales(command: Command): void;
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CommandHandler = void 0;
4
- const types_1 = require("../types");
4
+ const node_fs_1 = require("node:fs");
5
5
  const node_path_1 = require("node:path");
6
6
  const common_1 = require("../common");
7
+ const Permissions_1 = require("../structures/extra/Permissions");
8
+ const types_1 = require("../types");
7
9
  const chat_1 = require("./applications/chat");
8
10
  const menu_1 = require("./applications/menu");
9
- const node_fs_1 = require("node:fs");
10
11
  class CommandHandler extends common_1.BaseHandler {
11
12
  logger;
12
13
  client;
@@ -89,22 +90,25 @@ class CommandHandler extends common_1.BaseHandler {
89
90
  return option.channel_types.some(ct => !cached.channel_types.includes(ct));
90
91
  }
91
92
  }
92
- return;
93
+ break;
93
94
  case types_1.ApplicationCommandOptionType.Subcommand:
94
95
  case types_1.ApplicationCommandOptionType.SubcommandGroup:
95
- if (option.options?.length !==
96
- cached.options?.length) {
97
- return true;
98
- }
99
- if (option.options &&
100
- cached.options)
101
- for (const i of option.options) {
102
- const cachedOption = cached.options.find(x => x.name === i.name);
103
- if (!cachedOption)
104
- return true;
105
- if (this.shouldUploadOption(i, cachedOption))
106
- return true;
96
+ {
97
+ if (option.options?.length !==
98
+ cached.options
99
+ ?.length) {
100
+ return true;
107
101
  }
102
+ if (option.options &&
103
+ cached.options)
104
+ for (const i of option.options) {
105
+ const cachedOption = cached.options.find(x => x.name === i.name);
106
+ if (!cachedOption)
107
+ return true;
108
+ if (this.shouldUploadOption(i, cachedOption))
109
+ return true;
110
+ }
111
+ }
108
112
  break;
109
113
  case types_1.ApplicationCommandOptionType.Integer:
110
114
  case types_1.ApplicationCommandOptionType.Number:
@@ -470,8 +474,8 @@ class CommandHandler extends common_1.BaseHandler {
470
474
  option.onPermissionsFail?.bind(option) ??
471
475
  commandInstance.onPermissionsFail?.bind(commandInstance) ??
472
476
  this.client.options.commands?.defaults?.onPermissionsFail;
473
- option.botPermissions ??= commandInstance.botPermissions;
474
- option.defaultMemberPermissions ??= commandInstance.defaultMemberPermissions;
477
+ option.botPermissions = new Permissions_1.PermissionsBitField().add(option.botPermissions ?? Permissions_1.PermissionsBitField.None, commandInstance.botPermissions);
478
+ option.defaultMemberPermissions ??= new Permissions_1.PermissionsBitField().add(option.defaultMemberPermissions ?? Permissions_1.PermissionsBitField.None, commandInstance.defaultMemberPermissions);
475
479
  option.contexts ??= commandInstance.contexts;
476
480
  option.integrationTypes ??= commandInstance.integrationTypes;
477
481
  option.props ??= commandInstance.props;
@@ -1,10 +1,10 @@
1
- import { type APIApplicationCommandInteractionDataOption, type APIAttachment, type APIGuildMember, type APIInteractionDataResolvedChannel, type APIInteractionGuildMember, type APIRole, type APIUser, ApplicationCommandOptionType } from '../types';
1
+ import { Attachment } from '../builders';
2
+ import { type GuildMemberStructure, type GuildRoleStructure, type InteractionGuildMemberStructure, type UserStructure } from '../client/transformers';
2
3
  import type { MakeRequired } from '../common';
3
4
  import { type AllChannels } from '../structures';
5
+ import { type APIApplicationCommandInteractionDataOption, type APIAttachment, type APIGuildMember, type APIInteractionDataResolvedChannel, type APIInteractionGuildMember, type APIRole, type APIUser, ApplicationCommandOptionType } from '../types';
4
6
  import type { Command, CommandAutocompleteOption, SubCommand } from './applications/chat';
5
7
  import type { UsingClient } from './applications/shared';
6
- import { type GuildMemberStructure, type GuildRoleStructure, type InteractionGuildMemberStructure, type UserStructure } from '../client/transformers';
7
- import { Attachment } from '../builders';
8
8
  export type ContextOptionsResolved = {
9
9
  members?: Record<string, APIGuildMember | Omit<APIGuildMember, 'user'> | APIInteractionGuildMember>;
10
10
  users?: Record<string, APIUser>;
@@ -31,7 +31,7 @@ export declare class OptionResolver {
31
31
  getGroup(): string | null;
32
32
  get(name: string): OptionResolved | undefined;
33
33
  getHoisted(name: string): OptionResolved | undefined;
34
- getValue(name: string): string | number | boolean | import("../structures").GuildMember | import("../structures").User | import("../structures").BaseChannel<import("../types").ChannelType> | import("../structures").DMChannel | import("../structures").CategoryChannel | Attachment | import("../structures").InteractionGuildMember | import("../structures").GuildRole | undefined;
34
+ getValue(name: string): string | number | boolean | import("../structures").BaseChannel<import("../types").ChannelType> | import("../structures").DMChannel | import("../structures").CategoryChannel | import("../structures").User | import("../structures").GuildMember | import("../structures").InteractionGuildMember | import("../structures").GuildRole | Attachment | undefined;
35
35
  private getTypedOption;
36
36
  getChannel(name: string, required?: true): AllChannels;
37
37
  getString(name: string, required?: true): string;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OptionResolver = void 0;
4
- const types_1 = require("../types");
5
- const structures_1 = require("../structures");
6
- const transformers_1 = require("../client/transformers");
7
4
  const builders_1 = require("../builders");
5
+ const transformers_1 = require("../client/transformers");
6
+ const structures_1 = require("../structures");
7
+ const types_1 = require("../types");
8
8
  class OptionResolver {
9
9
  client;
10
10
  parent;
@@ -59,69 +59,69 @@ type Timestamp = `<t:${number}:${TimestampStyle}>`;
59
59
  /**
60
60
  * Represents a formatter utility for formatting content.
61
61
  */
62
- export declare class Formatter {
62
+ export declare const Formatter: {
63
63
  /**
64
64
  * Formats a code block.
65
65
  * @param content The content of the code block.
66
66
  * @param language The language of the code block. Defaults to 'txt'.
67
67
  * @returns The formatted code block.
68
68
  */
69
- static codeBlock(content: string, language?: string): string;
69
+ codeBlock(content: string, language?: string): string;
70
70
  /**
71
71
  * Formats content into inline code.
72
72
  * @param content The content to format.
73
73
  * @returns The formatted content.
74
74
  */
75
- static inlineCode(content: string): `\`${string}\``;
75
+ inlineCode(content: string): `\`${string}\``;
76
76
  /**
77
77
  * Formats content into bold text.
78
78
  * @param content The content to format.
79
79
  * @returns The formatted content.
80
80
  */
81
- static bold(content: string): `**${string}**`;
81
+ bold(content: string): `**${string}**`;
82
82
  /**
83
83
  * Formats content into italic text.
84
84
  * @param content The content to format.
85
85
  * @returns The formatted content.
86
86
  */
87
- static italic(content: string): `*${string}*`;
87
+ italic(content: string): `*${string}*`;
88
88
  /**
89
89
  * Formats content into underlined text.
90
90
  * @param content The content to format.
91
91
  * @returns The formatted content.
92
92
  */
93
- static underline(content: string): `__${string}__`;
93
+ underline(content: string): `__${string}__`;
94
94
  /**
95
95
  * Formats content into strikethrough text.
96
96
  * @param content The content to format.
97
97
  * @returns The formatted content.
98
98
  */
99
- static strikeThrough(content: string): `~~${string}~~`;
99
+ strikeThrough(content: string): `~~${string}~~`;
100
100
  /**
101
101
  * Formats content into a hyperlink.
102
102
  * @param content The content to format.
103
103
  * @param url The URL to hyperlink to.
104
104
  * @returns The formatted content.
105
105
  */
106
- static hyperlink(content: string, url: string): `[${string}](${string})`;
106
+ hyperlink(content: string, url: string): `[${string}](${string})`;
107
107
  /**
108
108
  * Formats content into a spoiler.
109
109
  * @param content The content to format.
110
110
  * @returns The formatted content.
111
111
  */
112
- static spoiler(content: string): `||${string}||`;
112
+ spoiler(content: string): `||${string}||`;
113
113
  /**
114
114
  * Formats content into a quote.
115
115
  * @param content The content to format.
116
116
  * @returns The formatted content.
117
117
  */
118
- static blockQuote(content: string): string;
118
+ blockQuote(content: string): string;
119
119
  /**
120
120
  * Formats content into a quote.
121
121
  * @param content The content to format.
122
122
  * @returns The formatted content.
123
123
  */
124
- static quote(content: string): string;
124
+ quote(content: string): string;
125
125
  /**
126
126
  * Formats a message link.
127
127
  * @param guildId The ID of the guild.
@@ -129,59 +129,59 @@ export declare class Formatter {
129
129
  * @param messageId The ID of the message.
130
130
  * @returns The formatted message link.
131
131
  */
132
- static messageLink(guildId: string, channelId: string, messageId: string): MessageLink;
132
+ messageLink(guildId: string, channelId: string, messageId: string): MessageLink;
133
133
  /**
134
134
  * Formats a header.
135
135
  * @param content The content of the header.
136
136
  * @param level The level of the header. Defaults to 1.
137
137
  * @returns The formatted header.
138
138
  */
139
- static header(content: string, level?: HeadingLevel): string;
139
+ header(content: string, level?: HeadingLevel): string;
140
140
  /**
141
141
  * Formats a list.
142
142
  * @param items The items of the list.
143
143
  * @param ordered Whether the list is ordered. Defaults to false.
144
144
  * @returns The formatted list.
145
145
  */
146
- static list(items: string[], ordered?: boolean): string;
146
+ list(items: string[], ordered?: boolean): string;
147
147
  /**
148
148
  * Formats the given timestamp into discord unix timestamp format.
149
149
  * @param timestamp The timestamp to format.
150
150
  * @param style The style of the timestamp. Defaults to 't'.
151
151
  * @returns The formatted timestamp.
152
152
  */
153
- static timestamp(timestamp: Date, style?: TimestampStyle): Timestamp;
153
+ timestamp(timestamp: Date, style?: TimestampStyle): Timestamp;
154
154
  /**
155
155
  * Formats a user mention.
156
156
  * @param userId The ID of the user to mention.
157
157
  * @returns The formatted user mention.
158
158
  */
159
- static userMention(userId: string): `<@${string}>`;
159
+ userMention(userId: string): `<@${string}>`;
160
160
  /**
161
161
  * Formats a role mention.
162
162
  * @param roleId The ID of the role to mention.
163
163
  * @returns The formatted role mention.
164
164
  */
165
- static roleMention(roleId: string): `<@&${string}>`;
165
+ roleMention(roleId: string): `<@&${string}>`;
166
166
  /**
167
167
  * Formats a channel mention.
168
168
  * @param channelId The ID of the channel to mention.
169
169
  * @returns The formatted channel mention.
170
170
  */
171
- static channelMention(channelId: string): `<#${string}>`;
171
+ channelMention(channelId: string): `<#${string}>`;
172
172
  /**
173
173
  * Formats an emoji.
174
174
  * @param emojiId The ID of the emoji.
175
175
  * @param animated Whether the emoji is animated. Defaults to false.
176
176
  * @returns The formatted emoji.
177
177
  */
178
- static emojiMention(emojiId: string, name: string | null, animated?: boolean): string;
178
+ emojiMention(emojiId: string, name: string | null, animated?: boolean): string;
179
179
  /**
180
180
  * Formats a channel link.
181
181
  * @param channelId The ID of the channel.
182
182
  * @param guildId The ID of the guild. Defaults to '@me'.
183
183
  * @returns The formatted channel link.
184
184
  */
185
- static channelLink(channelId: string, guildId?: string): string;
186
- }
185
+ channelLink(channelId: string, guildId?: string): string;
186
+ };
187
187
  export {};