seyfert 2.1.0 → 2.1.1-dev-11310514874.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 (240) 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 +3 -3
  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 +4 -4
  86. package/lib/commands/applications/shared.d.ts +5 -2
  87. package/lib/commands/basecontext.d.ts +1 -1
  88. package/lib/commands/decorators.d.ts +10 -10
  89. package/lib/commands/decorators.js +5 -4
  90. package/lib/commands/handle.d.ts +9 -9
  91. package/lib/commands/handle.js +94 -68
  92. package/lib/commands/handler.d.ts +5 -5
  93. package/lib/commands/handler.js +21 -17
  94. package/lib/commands/optionresolver.d.ts +4 -4
  95. package/lib/commands/optionresolver.js +3 -3
  96. package/lib/common/it/formatter.d.ts +21 -21
  97. package/lib/common/it/formatter.js +40 -41
  98. package/lib/common/it/logger.js +1 -1
  99. package/lib/common/it/utils.d.ts +4 -3
  100. package/lib/common/it/utils.js +52 -27
  101. package/lib/common/shorters/application.d.ts +2 -3
  102. package/lib/common/shorters/application.js +3 -3
  103. package/lib/common/shorters/bans.js +1 -1
  104. package/lib/common/shorters/channels.d.ts +3 -3
  105. package/lib/common/shorters/channels.js +3 -3
  106. package/lib/common/shorters/emojis.js +4 -4
  107. package/lib/common/shorters/guilds.d.ts +3 -3
  108. package/lib/common/shorters/guilds.js +5 -9
  109. package/lib/common/shorters/interaction.d.ts +3 -3
  110. package/lib/common/shorters/interaction.js +6 -5
  111. package/lib/common/shorters/members.d.ts +4 -5
  112. package/lib/common/shorters/members.js +6 -7
  113. package/lib/common/shorters/messages.d.ts +1 -1
  114. package/lib/common/shorters/messages.js +4 -4
  115. package/lib/common/shorters/reactions.d.ts +1 -1
  116. package/lib/common/shorters/reactions.js +1 -1
  117. package/lib/common/shorters/roles.js +1 -1
  118. package/lib/common/shorters/templates.js +2 -2
  119. package/lib/common/shorters/threads.d.ts +1 -1
  120. package/lib/common/shorters/threads.js +17 -11
  121. package/lib/common/shorters/webhook.d.ts +1 -1
  122. package/lib/common/shorters/webhook.js +4 -4
  123. package/lib/common/types/options.d.ts +2 -2
  124. package/lib/common/types/resolvables.d.ts +1 -1
  125. package/lib/common/types/util.d.ts +4 -1
  126. package/lib/common/types/write.d.ts +1 -1
  127. package/lib/components/BaseComponent.js +1 -1
  128. package/lib/components/ButtonComponent.d.ts +1 -1
  129. package/lib/components/componentcommand.d.ts +1 -1
  130. package/lib/components/componentcontext.d.ts +4 -4
  131. package/lib/components/componentcontext.js +1 -1
  132. package/lib/components/handler.d.ts +10 -8
  133. package/lib/components/handler.js +16 -13
  134. package/lib/components/index.js +2 -1
  135. package/lib/components/modalcontext.d.ts +2 -2
  136. package/lib/components/modalcontext.js +1 -1
  137. package/lib/deps/mixer.d.ts +1 -1
  138. package/lib/events/handler.d.ts +5 -5
  139. package/lib/events/handler.js +66 -16
  140. package/lib/events/hooks/application_command.d.ts +1 -1
  141. package/lib/events/hooks/auto_moderation.d.ts +1 -1
  142. package/lib/events/hooks/auto_moderation.js +1 -1
  143. package/lib/events/hooks/channel.d.ts +1 -1
  144. package/lib/events/hooks/dispatch.d.ts +1 -1
  145. package/lib/events/hooks/entitlement.d.ts +4 -5
  146. package/lib/events/hooks/entitlement.js +4 -4
  147. package/lib/events/hooks/guild.d.ts +3 -3
  148. package/lib/events/hooks/guild.js +1 -1
  149. package/lib/events/hooks/index.d.ts +1 -0
  150. package/lib/events/hooks/index.js +1 -0
  151. package/lib/events/hooks/integration.d.ts +1 -1
  152. package/lib/events/hooks/integration.js +1 -1
  153. package/lib/events/hooks/interactions.d.ts +3 -3
  154. package/lib/events/hooks/invite.d.ts +1 -1
  155. package/lib/events/hooks/message.d.ts +3 -3
  156. package/lib/events/hooks/message.js +1 -1
  157. package/lib/events/hooks/presence.d.ts +2 -2
  158. package/lib/events/hooks/soundboard.d.ts +155 -0
  159. package/lib/events/hooks/soundboard.js +28 -0
  160. package/lib/events/hooks/stage.d.ts +2 -2
  161. package/lib/events/hooks/thread.d.ts +2 -2
  162. package/lib/events/hooks/thread.js +2 -2
  163. package/lib/events/hooks/typing.d.ts +1 -1
  164. package/lib/events/hooks/typing.js +1 -1
  165. package/lib/events/hooks/user.d.ts +2 -2
  166. package/lib/events/hooks/voice.d.ts +2 -2
  167. package/lib/events/hooks/voice.js +1 -1
  168. package/lib/events/hooks/webhook.d.ts +1 -1
  169. package/lib/index.d.ts +2 -2
  170. package/lib/index.js +3 -5
  171. package/lib/langs/handler.d.ts +2 -2
  172. package/lib/structures/Guild.d.ts +7 -4
  173. package/lib/structures/Guild.js +1 -1
  174. package/lib/structures/GuildBan.d.ts +1 -1
  175. package/lib/structures/GuildMember.d.ts +7 -5
  176. package/lib/structures/GuildMember.js +5 -3
  177. package/lib/structures/GuildRole.d.ts +1 -1
  178. package/lib/structures/GuildTemplate.d.ts +1 -1
  179. package/lib/structures/Interaction.d.ts +17 -14
  180. package/lib/structures/Interaction.js +28 -21
  181. package/lib/structures/Message.d.ts +4 -7
  182. package/lib/structures/Message.js +5 -5
  183. package/lib/structures/Poll.d.ts +3 -3
  184. package/lib/structures/Sticker.d.ts +2 -2
  185. package/lib/structures/Sticker.js +1 -1
  186. package/lib/structures/VoiceState.d.ts +2 -1
  187. package/lib/structures/VoiceState.js +1 -1
  188. package/lib/structures/Webhook.d.ts +3 -3
  189. package/lib/structures/Webhook.js +1 -1
  190. package/lib/structures/channels.d.ts +4 -4
  191. package/lib/structures/channels.js +6 -5
  192. package/lib/structures/extra/BitField.d.ts +3 -3
  193. package/lib/structures/extra/BitField.js +34 -33
  194. package/lib/structures/extra/DiscordBase.js +1 -1
  195. package/lib/structures/extra/Permissions.d.ts +2 -0
  196. package/lib/structures/extra/Permissions.js +21 -0
  197. package/lib/types/gateway.d.ts +53 -5
  198. package/lib/types/payloads/_interactions/base.d.ts +1 -1
  199. package/lib/types/payloads/channel.d.ts +2 -2
  200. package/lib/types/payloads/guild.d.ts +9 -1
  201. package/lib/types/payloads/guild.js +8 -0
  202. package/lib/types/payloads/index.d.ts +1 -0
  203. package/lib/types/payloads/index.js +1 -0
  204. package/lib/types/payloads/soundboard.d.ts +23 -0
  205. package/lib/types/payloads/soundboard.js +5 -0
  206. package/lib/types/payloads/user.js +0 -1
  207. package/lib/types/rest/application.d.ts +3 -3
  208. package/lib/types/rest/auditLog.d.ts +1 -1
  209. package/lib/types/rest/channel.d.ts +2 -2
  210. package/lib/types/rest/guild.d.ts +2 -2
  211. package/lib/types/rest/guildScheduledEvent.d.ts +1 -1
  212. package/lib/types/rest/index.d.ts +1 -0
  213. package/lib/types/rest/index.js +1 -0
  214. package/lib/types/rest/oauth2.d.ts +1 -1
  215. package/lib/types/rest/poll.d.ts +1 -1
  216. package/lib/types/rest/soundboard.d.ts +64 -0
  217. package/lib/types/rest/soundboard.js +2 -0
  218. package/lib/types/rest/stageInstance.d.ts +1 -1
  219. package/lib/types/rest/template.d.ts +1 -1
  220. package/lib/types/rest/user.d.ts +1 -1
  221. package/lib/types/rest/webhook.d.ts +1 -1
  222. package/lib/types/utils/index.d.ts +11 -2
  223. package/lib/types/utils/index.js +10 -2
  224. package/lib/websocket/SharedTypes.d.ts +11 -2
  225. package/lib/websocket/constants/index.js +0 -10
  226. package/lib/websocket/discord/basesocket.d.ts +1 -1
  227. package/lib/websocket/discord/shard.d.ts +1 -1
  228. package/lib/websocket/discord/shard.js +25 -16
  229. package/lib/websocket/discord/sharder.d.ts +9 -6
  230. package/lib/websocket/discord/sharder.js +91 -74
  231. package/lib/websocket/discord/shared.d.ts +3 -14
  232. package/lib/websocket/discord/socket/custom.js +19 -6
  233. package/lib/websocket/discord/worker.d.ts +8 -2
  234. package/lib/websocket/discord/workermanager.d.ts +42 -17
  235. package/lib/websocket/discord/workermanager.js +144 -37
  236. package/lib/websocket/structures/timeout.d.ts +4 -5
  237. package/lib/websocket/structures/timeout.js +23 -24
  238. package/package.json +72 -70
  239. package/lib/cache/resources/threads.d.ts +0 -14
  240. package/lib/cache/resources/threads.js +0 -32
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MenuCommandContext = void 0;
4
- const types_1 = require("../../types");
4
+ const transformers_1 = require("../../client/transformers");
5
5
  const common_1 = require("../../common");
6
+ const types_1 = require("../../types");
6
7
  const basecontext_1 = require("../basecontext");
7
- const transformers_1 = require("../../client/transformers");
8
8
  class MenuCommandContext extends basecontext_1.BaseContext {
9
9
  client;
10
10
  interaction;
@@ -38,8 +38,8 @@ class MenuCommandContext extends basecontext_1.BaseContext {
38
38
  get fullCommandName() {
39
39
  return this.command.name;
40
40
  }
41
- write(body, fetchReply) {
42
- return this.interaction.write(body, fetchReply);
41
+ write(body, withResponse) {
42
+ return this.interaction.write(body, withResponse);
43
43
  }
44
44
  modal(body) {
45
45
  return this.interaction.modal(body);
@@ -53,8 +53,8 @@ class MenuCommandContext extends basecontext_1.BaseContext {
53
53
  deleteResponse() {
54
54
  return this.interaction.deleteResponse();
55
55
  }
56
- editOrReply(body, fetchReply) {
57
- return this.interaction.editOrReply(body, fetchReply);
56
+ editOrReply(body, withResponse) {
57
+ return this.interaction.editOrReply(body, withResponse);
58
58
  }
59
59
  fetchResponse() {
60
60
  return this.interaction.fetchResponse();
@@ -1,11 +1,11 @@
1
- import { ApplicationCommandOptionType, type APIApplicationCommandOptionChoice, type ChannelType } from '../../types';
2
1
  import type { AutocompleteCallback, EntryPointContext, MenuCommandContext, OnAutocompleteErrorCallback, ReturnOptionsTypes, __TypesWrapper } from '..';
2
+ import type { ModalContext } from '../../components';
3
+ import type { ComponentContext } from '../../components/componentcontext';
3
4
  import type { MessageCommandInteraction, UserCommandInteraction } from '../../structures';
5
+ import { type APIApplicationCommandOptionChoice, ApplicationCommandOptionType, type ChannelType } from '../../types';
4
6
  import type { CommandContext } from './chatcontext';
5
7
  import type { MiddlewareContext } from './shared';
6
- import type { ModalContext } from '../../components';
7
- import type { ComponentContext } from '../../components/componentcontext';
8
- export type SeyfertBasicOption<T extends keyof __TypesWrapper, D = {}> = __TypesWrapper[T] & D;
8
+ export type SeyfertBasicOption<T extends keyof __TypesWrapper, D = object> = __TypesWrapper[T] & D;
9
9
  export type SeyfertStringOption = SeyfertBasicOption<'String'> & {
10
10
  autocomplete?: AutocompleteCallback;
11
11
  onAutocompleteError?: OnAutocompleteErrorCallback;
@@ -20,6 +20,9 @@ export interface ExtraProps {
20
20
  export interface UsingClient extends BaseClient {
21
21
  }
22
22
  export type ParseClient<T extends BaseClient> = T;
23
+ export type ParseGlobalMiddlewares<T extends Record<string, MiddlewareContext>> = {
24
+ [K in keyof T]: MetadataMiddleware<T[K]>;
25
+ };
23
26
  export interface InternalOptions {
24
27
  }
25
28
  export interface CustomStructures {
@@ -34,9 +37,9 @@ export type MetadataMiddleware<T extends MiddlewareContext> = IsStrictlyUndefine
34
37
  export type CommandMetadata<T extends readonly (keyof RegisteredMiddlewares)[]> = T extends readonly [
35
38
  infer first,
36
39
  ...infer rest
37
- ] ? first extends keyof RegisteredMiddlewares ? (MetadataMiddleware<RegisteredMiddlewares[first]> extends never ? {} : {
40
+ ] ? first extends keyof RegisteredMiddlewares ? (MetadataMiddleware<RegisteredMiddlewares[first]> extends never ? never : {
38
41
  [key in first]: MetadataMiddleware<RegisteredMiddlewares[first]>;
39
- }) & (rest extends readonly (keyof RegisteredMiddlewares)[] ? CommandMetadata<rest> : {}) : {} : {};
42
+ }) & (rest extends readonly (keyof RegisteredMiddlewares)[] ? CommandMetadata<rest> : never) : never : never;
40
43
  export type MessageCommandOptionErrors = ['CHANNEL_TYPES', type: ChannelType[]] | ['STRING_MIN_LENGTH', min: number] | ['STRING_MAX_LENGTH', max: number] | ['STRING_INVALID_CHOICE', choices: readonly {
41
44
  name: string;
42
45
  value: string;
@@ -1,5 +1,5 @@
1
1
  import type { ModalContext } from '../components';
2
- import type { ContextComponentCommandInteractionMap, ComponentContext } from '../components/componentcontext';
2
+ import type { ComponentContext, ContextComponentCommandInteractionMap } from '../components/componentcontext';
3
3
  import type { MessageCommandInteraction, UserCommandInteraction } from '../structures';
4
4
  import type { CommandContext } from './applications/chatcontext';
5
5
  import type { MenuCommandContext } from './applications/menucontext';
@@ -1,5 +1,5 @@
1
- import { ApplicationCommandType, ApplicationIntegrationType, type EntryPointCommandHandlerType, InteractionContextType, type LocaleString } from '../types';
2
1
  import type { FlatObjectKeys, PermissionStrings } from '../common';
2
+ import { ApplicationCommandType, ApplicationIntegrationType, type EntryPointCommandHandlerType, InteractionContextType, type LocaleString } from '../types';
3
3
  import type { CommandOption, OptionsRecord, SubCommand } from './applications/chat';
4
4
  import type { DefaultLocale, ExtraProps, IgnoreCommand, MiddlewareContext } from './applications/shared';
5
5
  export interface RegisteredMiddlewares {
@@ -27,7 +27,7 @@ export declare function Locales({ name: names, description: descriptions, }: {
27
27
  name?: [language: LocaleString, value: string][];
28
28
  description?: [language: LocaleString, value: string][];
29
29
  }): <T extends {
30
- new (...args: any[]): {};
30
+ new (...args: any[]): object;
31
31
  }>(target: T) => {
32
32
  new (...args: any[]): {
33
33
  name_localizations: {
@@ -39,7 +39,7 @@ export declare function Locales({ name: names, description: descriptions, }: {
39
39
  };
40
40
  } & T;
41
41
  export declare function LocalesT(name?: FlatObjectKeys<DefaultLocale>, description?: FlatObjectKeys<DefaultLocale>): <T extends {
42
- new (...args: any[]): {};
42
+ new (...args: any[]): object;
43
43
  }>(target: T) => {
44
44
  new (...args: any[]): {
45
45
  __t: {
@@ -54,7 +54,7 @@ export declare function GroupsT(groups: Record<string, {
54
54
  defaultDescription: string;
55
55
  aliases?: string[];
56
56
  }>): <T extends {
57
- new (...args: any[]): {};
57
+ new (...args: any[]): object;
58
58
  }>(target: T) => {
59
59
  new (...args: any[]): {
60
60
  __tGroups: Record<string, {
@@ -72,7 +72,7 @@ export declare function Groups(groups: Record<string, {
72
72
  defaultDescription: string;
73
73
  aliases?: string[];
74
74
  }>): <T extends {
75
- new (...args: any[]): {};
75
+ new (...args: any[]): object;
76
76
  }>(target: T) => {
77
77
  new (...args: any[]): {
78
78
  groups: Record<string, {
@@ -85,21 +85,21 @@ export declare function Groups(groups: Record<string, {
85
85
  };
86
86
  } & T;
87
87
  export declare function Group(groupName: string): <T extends {
88
- new (...args: any[]): {};
88
+ new (...args: any[]): object;
89
89
  }>(target: T) => {
90
90
  new (...args: any[]): {
91
91
  group: string;
92
92
  };
93
93
  } & T;
94
94
  export declare function Options(options: (new () => SubCommand)[] | OptionsRecord): <T extends {
95
- new (...args: any[]): {};
95
+ new (...args: any[]): object;
96
96
  }>(target: T) => {
97
97
  new (...args: any[]): {
98
98
  options: SubCommand[] | CommandOption[];
99
99
  };
100
100
  } & T;
101
101
  export declare function AutoLoad(): <T extends {
102
- new (...args: any[]): {};
102
+ new (...args: any[]): object;
103
103
  }>(target: T) => {
104
104
  new (...args: any[]): {
105
105
  __autoload: boolean;
@@ -109,14 +109,14 @@ export type ParseMiddlewares<T extends Record<string, MiddlewareContext>> = {
109
109
  [k in keyof T]: T[k];
110
110
  };
111
111
  export declare function Middlewares(cbs: readonly (keyof RegisteredMiddlewares)[]): <T extends {
112
- new (...args: any[]): {};
112
+ new (...args: any[]): object;
113
113
  }>(target: T) => {
114
114
  new (...args: any[]): {
115
115
  middlewares: readonly never[];
116
116
  };
117
117
  } & T;
118
118
  export declare function Declare(declare: CommandDeclareOptions): <T extends {
119
- new (...args: any[]): {};
119
+ new (...args: any[]): object;
120
120
  }>(target: T) => {
121
121
  new (...args: any[]): {
122
122
  name: string;
@@ -9,6 +9,7 @@ exports.Options = Options;
9
9
  exports.AutoLoad = AutoLoad;
10
10
  exports.Middlewares = Middlewares;
11
11
  exports.Declare = Declare;
12
+ const Permissions_1 = require("../structures/extra/Permissions");
12
13
  const types_1 = require("../types");
13
14
  function Locales({ name: names, description: descriptions, }) {
14
15
  return (target) => class extends target {
@@ -86,11 +87,11 @@ function Declare(declare) {
86
87
  integrationTypes = declare.integrationTypes?.map(i => types_1.ApplicationIntegrationType[i]) ?? [
87
88
  types_1.ApplicationIntegrationType.GuildInstall,
88
89
  ];
89
- defaultMemberPermissions = Array.isArray(declare.defaultMemberPermissions)
90
- ? declare.defaultMemberPermissions?.reduce((acc, prev) => acc | types_1.PermissionFlagsBits[prev], BigInt(0))
90
+ defaultMemberPermissions = declare.defaultMemberPermissions
91
+ ? Permissions_1.PermissionsBitField.resolve(declare.defaultMemberPermissions)
91
92
  : declare.defaultMemberPermissions;
92
- botPermissions = Array.isArray(declare.botPermissions)
93
- ? declare.botPermissions?.reduce((acc, prev) => acc | types_1.PermissionFlagsBits[prev], BigInt(0))
93
+ botPermissions = declare.botPermissions
94
+ ? Permissions_1.PermissionsBitField.resolve(declare.botPermissions)
94
95
  : declare.botPermissions;
95
96
  description = '';
96
97
  type = types_1.ApplicationCommandType.ChatInput;
@@ -1,9 +1,9 @@
1
- import { type APIApplicationCommandInteraction, type APIInteraction, type GatewayMessageCreateDispatchData, type APIApplicationCommandInteractionDataOption, ApplicationCommandOptionType } from '../types';
2
- import { Command, type ContextOptionsResolved, type UsingClient, type CommandAutocompleteOption, type ContextMenuCommand, MenuCommandContext, CommandContext, SubCommand, type CommandOption, type MessageCommandOptionErrors, EntryPointContext, type EntryPointCommand } from '.';
3
- import { AutocompleteInteraction, type ComponentInteraction, type ModalSubmitInteraction, type ChatInputCommandInteraction, type MessageCommandInteraction, type UserCommandInteraction, type __InternalReplyFunction, type EntryPointInteraction } from '../structures';
4
- import type { PermissionsBitField } from '../structures/extra/Permissions';
1
+ import { Command, type CommandAutocompleteOption, CommandContext, type CommandOption, type ContextMenuCommand, type ContextOptionsResolved, type EntryPointCommand, EntryPointContext, MenuCommandContext, type MessageCommandOptionErrors, SubCommand, type UsingClient } from '.';
2
+ import { type MessageStructure, type OptionResolverStructure, Transformers } from '../client/transformers';
5
3
  import type { MakeRequired } from '../common';
6
- import { type MessageStructure, Transformers, type OptionResolverStructure } from '../client/transformers';
4
+ import { AutocompleteInteraction, type ChatInputCommandInteraction, type ComponentInteraction, type EntryPointInteraction, type MessageCommandInteraction, type ModalSubmitInteraction, type UserCommandInteraction, type __InternalReplyFunction } from '../structures';
5
+ import type { PermissionsBitField } from '../structures/extra/Permissions';
6
+ import { type APIApplicationCommandInteraction, type APIApplicationCommandInteractionDataOption, type APIInteraction, ApplicationCommandOptionType, type GatewayMessageCreateDispatchData } from '../types';
7
7
  export type CommandOptionWithType = CommandOption & {
8
8
  type: ApplicationCommandOptionType;
9
9
  };
@@ -36,10 +36,10 @@ export declare class HandleCommand {
36
36
  name: string;
37
37
  }): T | undefined;
38
38
  checkPermissions(app: PermissionsBitField, bot: bigint): import("../common").PermissionStrings | undefined;
39
- fetchChannel(_option: CommandOptionWithType, query: string): Promise<import("../types").APIChannel | null>;
40
- fetchUser(_option: CommandOptionWithType, query: string): Promise<import("../types").APIUser | null>;
41
- fetchMember(_option: CommandOptionWithType, query: string, guildId: string): Promise<import("../types").APIGuildMember | null>;
42
- fetchRole(_option: CommandOptionWithType, query: string, guildId?: string): Promise<import("../types").APIRole | null | undefined>;
39
+ fetchChannel(_option: CommandOptionWithType, query: string): Promise<import("../types").APIChannel> | null;
40
+ fetchUser(_option: CommandOptionWithType, query: string): Promise<import("../types").APIUser> | null;
41
+ fetchMember(_option: CommandOptionWithType, query: string, guildId: string): Promise<import("../types").APIGuildMember> | null;
42
+ fetchRole(_option: CommandOptionWithType, query: string, guildId?: string): Promise<import("../types").APIRole> | null;
43
43
  runGlobalMiddlewares(command: Command | ContextMenuCommand | SubCommand | EntryPointCommand, context: CommandContext<{}, never> | MenuCommandContext<any> | EntryPointContext): Promise<false | {
44
44
  error?: string;
45
45
  pass?: boolean;
@@ -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;