seyfert 1.1.0 → 1.2.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 (171) hide show
  1. package/lib/api/Routes/applications.d.ts +2 -2
  2. package/lib/api/Routes/channels.d.ts +2 -2
  3. package/lib/api/Routes/gateway.d.ts +2 -2
  4. package/lib/api/Routes/guilds.d.ts +2 -1
  5. package/lib/api/Routes/interactions.d.ts +2 -2
  6. package/lib/api/Routes/invites.d.ts +2 -2
  7. package/lib/api/Routes/stage-instances.d.ts +2 -2
  8. package/lib/api/Routes/stickers.d.ts +2 -2
  9. package/lib/api/Routes/users.d.ts +2 -2
  10. package/lib/api/Routes/voice.d.ts +2 -2
  11. package/lib/api/Routes/webhooks.d.ts +2 -2
  12. package/lib/builders/ActionRow.d.ts +2 -1
  13. package/lib/builders/ActionRow.js +3 -3
  14. package/lib/builders/Base.d.ts +1 -1
  15. package/lib/builders/Button.d.ts +2 -1
  16. package/lib/builders/Button.js +2 -2
  17. package/lib/builders/Embed.d.ts +2 -1
  18. package/lib/builders/Modal.d.ts +9 -2
  19. package/lib/builders/Modal.js +12 -3
  20. package/lib/builders/SelectMenu.d.ts +18 -1
  21. package/lib/builders/SelectMenu.js +36 -12
  22. package/lib/builders/index.d.ts +1 -1
  23. package/lib/builders/index.js +9 -9
  24. package/lib/builders/types.d.ts +1 -1
  25. package/lib/cache/adapters/types.d.ts +23 -23
  26. package/lib/cache/index.d.ts +5 -5
  27. package/lib/cache/index.js +3 -3
  28. package/lib/cache/resources/default/base.d.ts +10 -10
  29. package/lib/cache/resources/default/guild-based.d.ts +7 -7
  30. package/lib/cache/resources/default/guild-based.js +2 -1
  31. package/lib/cache/resources/default/guild-related.d.ts +9 -9
  32. package/lib/cache/resources/default/guild-related.js +2 -1
  33. package/lib/cache/resources/presence.d.ts +1 -1
  34. package/lib/cache/resources/stage-instances.d.ts +1 -1
  35. package/lib/cache/resources/voice-states.d.ts +1 -1
  36. package/lib/client/base.d.ts +19 -12
  37. package/lib/client/base.js +45 -7
  38. package/lib/client/client.d.ts +7 -4
  39. package/lib/client/client.js +21 -9
  40. package/lib/client/httpclient.d.ts +2 -1
  41. package/lib/client/httpclient.js +3 -3
  42. package/lib/client/oninteractioncreate.js +18 -19
  43. package/lib/client/onmessagecreate.js +6 -4
  44. package/lib/client/workerclient.d.ts +11 -5
  45. package/lib/client/workerclient.js +18 -11
  46. package/lib/commands/applications/chat.d.ts +4 -4
  47. package/lib/commands/applications/chat.js +17 -9
  48. package/lib/commands/applications/chatcontext.d.ts +7 -10
  49. package/lib/commands/applications/chatcontext.js +6 -17
  50. package/lib/commands/applications/menu.d.ts +2 -1
  51. package/lib/commands/applications/menu.js +7 -5
  52. package/lib/commands/applications/menucontext.d.ts +5 -9
  53. package/lib/commands/applications/menucontext.js +8 -21
  54. package/lib/commands/applications/shared.d.ts +5 -4
  55. package/lib/commands/basecontex.d.ts +15 -0
  56. package/lib/commands/basecontex.js +34 -0
  57. package/lib/commands/decorators.d.ts +3 -2
  58. package/lib/commands/decorators.js +5 -5
  59. package/lib/commands/handler.d.ts +6 -0
  60. package/lib/commands/handler.js +10 -4
  61. package/lib/commands/optionresolver.d.ts +3 -3
  62. package/lib/commands/optionresolver.js +14 -14
  63. package/lib/common/index.d.ts +0 -1
  64. package/lib/common/index.js +0 -1
  65. package/lib/common/it/constants.d.ts +3 -1
  66. package/lib/common/it/constants.js +2 -0
  67. package/lib/common/it/utils.d.ts +1 -0
  68. package/lib/common/it/utils.js +2 -1
  69. package/lib/common/shorters/channels.d.ts +1 -1
  70. package/lib/common/shorters/channels.js +4 -4
  71. package/lib/common/shorters/guilds.d.ts +1 -1
  72. package/lib/common/shorters/guilds.js +6 -1
  73. package/lib/common/shorters/members.d.ts +6 -1
  74. package/lib/common/shorters/members.js +25 -2
  75. package/lib/common/shorters/messages.d.ts +1 -1
  76. package/lib/common/shorters/messages.js +1 -1
  77. package/lib/common/shorters/users.d.ts +0 -6
  78. package/lib/common/shorters/users.js +0 -34
  79. package/lib/common/shorters/webhook.d.ts +2 -2
  80. package/lib/common/types/resolvables.d.ts +2 -1
  81. package/lib/common/types/util.d.ts +4 -1
  82. package/lib/common/types/write.d.ts +1 -1
  83. package/lib/components/ActionRow.d.ts +4 -3
  84. package/lib/components/ActionRow.js +6 -3
  85. package/lib/components/BaseComponent.d.ts +18 -0
  86. package/lib/components/BaseComponent.js +21 -0
  87. package/lib/components/BaseSelectMenuComponent.d.ts +10 -0
  88. package/lib/components/BaseSelectMenuComponent.js +22 -0
  89. package/lib/components/ButtonComponent.d.ts +14 -14
  90. package/lib/components/ButtonComponent.js +36 -25
  91. package/lib/components/ChannelSelectMenuComponent.d.ts +4 -4
  92. package/lib/components/ChannelSelectMenuComponent.js +6 -5
  93. package/lib/components/MentionableSelectMenuComponent.d.ts +3 -2
  94. package/lib/components/MentionableSelectMenuComponent.js +4 -1
  95. package/lib/components/RoleSelectMenuComponent.d.ts +3 -2
  96. package/lib/components/RoleSelectMenuComponent.js +4 -1
  97. package/lib/components/StringSelectMenuComponent.d.ts +3 -4
  98. package/lib/components/StringSelectMenuComponent.js +3 -5
  99. package/lib/components/TextInputComponent.d.ts +10 -5
  100. package/lib/components/TextInputComponent.js +24 -7
  101. package/lib/components/UserSelectMenuComponent.d.ts +3 -2
  102. package/lib/components/UserSelectMenuComponent.js +4 -1
  103. package/lib/components/command.d.ts +6 -5
  104. package/lib/components/command.js +4 -0
  105. package/lib/components/componentcontext.d.ts +42 -0
  106. package/lib/components/componentcontext.js +79 -0
  107. package/lib/components/handler.d.ts +22 -6
  108. package/lib/components/handler.js +19 -12
  109. package/lib/components/index.d.ts +2 -2
  110. package/lib/components/index.js +9 -9
  111. package/lib/events/handler.d.ts +12 -3
  112. package/lib/events/handler.js +6 -8
  113. package/lib/events/hooks/application_command.d.ts +2 -2
  114. package/lib/events/hooks/auto_moderation.d.ts +4 -4
  115. package/lib/events/hooks/channel.d.ts +1 -1
  116. package/lib/events/hooks/dispatch.d.ts +1 -1
  117. package/lib/events/hooks/entitlement.d.ts +4 -4
  118. package/lib/events/hooks/guild.d.ts +42 -42
  119. package/lib/events/hooks/integration.d.ts +19 -19
  120. package/lib/events/hooks/interactions.d.ts +2 -2
  121. package/lib/events/hooks/invite.d.ts +5 -5
  122. package/lib/events/hooks/message.d.ts +6 -5
  123. package/lib/events/hooks/presence.d.ts +7 -7
  124. package/lib/events/hooks/stage.d.ts +4 -4
  125. package/lib/events/hooks/thread.d.ts +49 -49
  126. package/lib/events/hooks/typing.d.ts +2 -2
  127. package/lib/events/hooks/user.d.ts +1 -1
  128. package/lib/events/hooks/voice.d.ts +2 -2
  129. package/lib/events/hooks/webhook.d.ts +1 -1
  130. package/lib/index.d.ts +3 -6
  131. package/lib/index.js +6 -7
  132. package/lib/langs/handler.d.ts +10 -1
  133. package/lib/langs/handler.js +1 -0
  134. package/lib/structures/AutoModerationRule.d.ts +3 -2
  135. package/lib/structures/ClientUser.d.ts +1 -1
  136. package/lib/structures/Guild.d.ts +27 -27
  137. package/lib/structures/GuildEmoji.d.ts +2 -1
  138. package/lib/structures/GuildMember.d.ts +16 -6
  139. package/lib/structures/GuildMember.js +35 -6
  140. package/lib/structures/GuildPreview.d.ts +1 -1
  141. package/lib/structures/GuildRole.d.ts +2 -1
  142. package/lib/structures/GuildTemplate.d.ts +3 -2
  143. package/lib/structures/Interaction.d.ts +5 -5
  144. package/lib/structures/Interaction.js +34 -34
  145. package/lib/structures/Message.d.ts +6 -5
  146. package/lib/structures/Sticker.d.ts +2 -1
  147. package/lib/structures/User.d.ts +7 -3
  148. package/lib/structures/User.js +5 -0
  149. package/lib/structures/Webhook.d.ts +63 -4
  150. package/lib/structures/Webhook.js +53 -0
  151. package/lib/structures/channels.d.ts +4 -4
  152. package/lib/structures/extra/BaseGuild.d.ts +2 -1
  153. package/lib/structures/extra/BaseGuild.js +3 -3
  154. package/lib/structures/extra/BitField.d.ts +2 -2
  155. package/lib/structures/extra/BitField.js +2 -2
  156. package/lib/structures/extra/Permissions.d.ts +1 -1
  157. package/lib/structures/extra/functions.d.ts +2 -1
  158. package/lib/structures/extra/functions.js +2 -1
  159. package/lib/types/index.d.ts +1 -0
  160. package/lib/types/index.js +17 -0
  161. package/lib/websocket/SharedTypes.d.ts +2 -1
  162. package/lib/websocket/SharedTypes.js +1 -0
  163. package/lib/websocket/discord/shard.d.ts +2 -1
  164. package/lib/websocket/discord/shard.js +30 -41
  165. package/lib/websocket/discord/sharder.d.ts +3 -2
  166. package/lib/websocket/discord/sharder.js +7 -6
  167. package/lib/websocket/discord/shared.d.ts +2 -1
  168. package/lib/websocket/discord/worker.d.ts +1 -1
  169. package/lib/websocket/discord/workermanager.d.ts +3 -2
  170. package/lib/websocket/discord/workermanager.js +1 -1
  171. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
+ import type { GatewayIntentBits } from 'discord-api-types/v10';
1
2
  import type { BaseClient } from '../../../client/base';
2
3
  import type { UsingClient } from '../../../commands';
3
- import { type GatewayIntentBits } from '../../../common';
4
4
  import type { Cache, ReturnCache } from '../../index';
5
5
  export declare class BaseResource<T = any> {
6
6
  protected cache: Cache;
@@ -9,19 +9,19 @@ export declare class BaseResource<T = any> {
9
9
  constructor(cache: Cache, client?: UsingClient);
10
10
  get rest(): import("../../..").ApiHandler;
11
11
  get adapter(): import("../../index").Adapter;
12
- removeIfNI(intent: keyof typeof GatewayIntentBits, id: string): import("../../index").RPV<void>;
12
+ removeIfNI(intent: keyof typeof GatewayIntentBits, id: string): import("../../../common").Awaitable<void>;
13
13
  setIfNI(intent: keyof typeof GatewayIntentBits, id: string, data: any): any;
14
14
  get(id: string): ReturnCache<T | undefined>;
15
15
  bulk(ids: string[]): ReturnCache<T[]>;
16
- set(id: string, data: any): import("../../index").RPV<void>;
17
- patch<T extends Record<any, any> = Record<any, any>>(id: string, data: T): import("../../index").RPV<void>;
18
- remove(id: string): import("../../index").RPV<void>;
16
+ set(id: string, data: any): import("../../../common").Awaitable<void>;
17
+ patch<T extends Record<any, any> = Record<any, any>>(id: string, data: T): import("../../../common").Awaitable<void>;
18
+ remove(id: string): import("../../../common").Awaitable<void>;
19
19
  keys(): ReturnCache<string[]>;
20
20
  values(): ReturnCache<T[]>;
21
- count(): import("../../index").RPV<number>;
22
- contains(id: string): import("../../index").RPV<boolean>;
23
- getToRelationship(): import("../../index").RPV<string[]>;
24
- addToRelationship(id: string | string[]): import("../../index").RPV<void>;
25
- removeToRelationship(id: string | string[]): import("../../index").RPV<void>;
21
+ count(): import("../../../common").Awaitable<number>;
22
+ contains(id: string): import("../../../common").Awaitable<boolean>;
23
+ getToRelationship(): import("../../../common").Awaitable<string[]>;
24
+ addToRelationship(id: string | string[]): import("../../../common").Awaitable<void>;
25
+ removeToRelationship(id: string | string[]): import("../../../common").Awaitable<void>;
26
26
  hashId(id: string): string;
27
27
  }
@@ -1,6 +1,6 @@
1
+ import type { GatewayIntentBits } from 'discord-api-types/v10';
1
2
  import type { BaseClient } from '../../../client/base';
2
3
  import type { UsingClient } from '../../../commands';
3
- import { type GatewayIntentBits } from '../../../common';
4
4
  import type { Cache, ReturnCache } from '../../index';
5
5
  export declare class GuildBasedResource<T = any> {
6
6
  protected cache: Cache;
@@ -9,7 +9,7 @@ export declare class GuildBasedResource<T = any> {
9
9
  constructor(cache: Cache, client?: UsingClient);
10
10
  parse(data: any, id: string, guild_id: string): any;
11
11
  get adapter(): import("../../index").Adapter;
12
- removeIfNI(intent: keyof typeof GatewayIntentBits, id: string | string[], guildId: string): import("../../index").RPV<void>;
12
+ removeIfNI(intent: keyof typeof GatewayIntentBits, id: string | string[], guildId: string): import("../../../common").Awaitable<void>;
13
13
  setIfNI(intent: keyof typeof GatewayIntentBits, id: string, guildId: string, data: any): any;
14
14
  get(id: string, guild: string): ReturnCache<(T & {
15
15
  guild_id: string;
@@ -21,17 +21,17 @@ export declare class GuildBasedResource<T = any> {
21
21
  set(__keys: [string, any][], guild: string): ReturnCache<void>;
22
22
  patch(__keys: string, guild: string, data: any): ReturnCache<void>;
23
23
  patch(__keys: [string, any][], guild: string): ReturnCache<void>;
24
- remove(id: string | string[], guild: string): import("../../index").RPV<void>;
24
+ remove(id: string | string[], guild: string): import("../../../common").Awaitable<void>;
25
25
  keys(guild: string): ReturnCache<string[]>;
26
26
  values(guild: string): ReturnCache<(T & {
27
27
  guild_id: string;
28
28
  })[]>;
29
29
  count(guild: string): ReturnCache<number>;
30
30
  contains(id: string, guild: string): ReturnCache<boolean>;
31
- getToRelationship(guild: string): import("../../index").RPV<string[]>;
32
- addToRelationship(id: string | string[], guild: string): import("../../index").RPV<void>;
33
- removeToRelationship(id: string | string[], guild: string): import("../../index").RPV<void>;
34
- removeRelationship(id: string | string[]): import("../../index").RPV<void>;
31
+ getToRelationship(guild: string): import("../../../common").Awaitable<string[]>;
32
+ addToRelationship(id: string | string[], guild: string): import("../../../common").Awaitable<void>;
33
+ removeToRelationship(id: string | string[], guild: string): import("../../../common").Awaitable<void>;
34
+ removeRelationship(id: string | string[]): import("../../../common").Awaitable<void>;
35
35
  hashId(id: string): string;
36
36
  hashGuildId(guild: string, id: string): string;
37
37
  }
@@ -17,7 +17,8 @@ class GuildBasedResource {
17
17
  this.client = client;
18
18
  }
19
19
  parse(data, id, guild_id) {
20
- data.id = id;
20
+ if (!data.id)
21
+ data.id = id;
21
22
  data.guild_id = guild_id;
22
23
  return data;
23
24
  }
@@ -1,6 +1,6 @@
1
+ import type { GatewayIntentBits } from 'discord-api-types/v10';
1
2
  import type { BaseClient } from '../../../client/base';
2
3
  import type { UsingClient } from '../../../commands';
3
- import { type GatewayIntentBits } from '../../../common';
4
4
  import type { Cache, ReturnCache } from '../../index';
5
5
  export declare class GuildRelatedResource<T = any> {
6
6
  protected cache: Cache;
@@ -9,7 +9,7 @@ export declare class GuildRelatedResource<T = any> {
9
9
  constructor(cache: Cache, client?: UsingClient);
10
10
  parse(data: any, id: string, guild_id: string): any;
11
11
  get adapter(): import("../../index").Adapter;
12
- removeIfNI(intent: keyof typeof GatewayIntentBits, id: string | string[], guildId: string): import("../../index").RPV<void>;
12
+ removeIfNI(intent: keyof typeof GatewayIntentBits, id: string | string[], guildId: string): import("../../../common").Awaitable<void>;
13
13
  setIfNI(intent: keyof typeof GatewayIntentBits, id: string, guildId: string, data: any): any;
14
14
  get(id: string): ReturnCache<(T & {
15
15
  guild_id: string;
@@ -21,16 +21,16 @@ export declare class GuildRelatedResource<T = any> {
21
21
  set(__keys: [string, any][], guild: string): ReturnCache<void>;
22
22
  patch(__keys: string, guild?: string, data?: any): ReturnCache<void>;
23
23
  patch(__keys: [string, any][], guild?: string): ReturnCache<void>;
24
- remove(id: string | string[], guild: string): import("../../index").RPV<void>;
24
+ remove(id: string | string[], guild: string): import("../../../common").Awaitable<void>;
25
25
  keys(guild: string): ReturnCache<string[]>;
26
26
  values(guild: string): ReturnCache<(T & {
27
27
  guild_id: string;
28
28
  })[]>;
29
- count(to: string): import("../../index").RPV<number>;
30
- contains(id: string, guild: string): import("../../index").RPV<boolean>;
31
- getToRelationship(guild: string): import("../../index").RPV<string[]>;
32
- addToRelationship(id: string | string[], guild: string): import("../../index").RPV<void>;
33
- removeToRelationship(id: string | string[], guild: string): import("../../index").RPV<void>;
34
- removeRelationship(id: string | string[]): import("../../index").RPV<void>;
29
+ count(to: string): import("../../../common").Awaitable<number>;
30
+ contains(id: string, guild: string): import("../../../common").Awaitable<boolean>;
31
+ getToRelationship(guild: string): import("../../../common").Awaitable<string[]>;
32
+ addToRelationship(id: string | string[], guild: string): import("../../../common").Awaitable<void>;
33
+ removeToRelationship(id: string | string[], guild: string): import("../../../common").Awaitable<void>;
34
+ removeRelationship(id: string | string[]): import("../../../common").Awaitable<void>;
35
35
  hashId(id: string): string;
36
36
  }
@@ -17,7 +17,8 @@ class GuildRelatedResource {
17
17
  this.client = client;
18
18
  }
19
19
  parse(data, id, guild_id) {
20
- data.id = id;
20
+ if (!data.id)
21
+ data.id = id;
21
22
  data.guild_id = guild_id;
22
23
  return data;
23
24
  }
@@ -1,4 +1,4 @@
1
- import type { GatewayPresenceUpdate } from '../../common';
1
+ import type { GatewayPresenceUpdate } from 'discord-api-types/v10';
2
2
  import { GuildRelatedResource } from './default/guild-related';
3
3
  export declare class Presences extends GuildRelatedResource<PresenceResource> {
4
4
  namespace: string;
@@ -1,4 +1,4 @@
1
- import type { APIStageInstance } from '../../common';
1
+ import type { APIStageInstance } from 'discord-api-types/v10';
2
2
  import { GuildRelatedResource } from './default/guild-related';
3
3
  export declare class StageInstances extends GuildRelatedResource<APIStageInstance> {
4
4
  namespace: string;
@@ -1,4 +1,4 @@
1
- import type { GatewayVoiceState } from '../../common';
1
+ import type { GatewayVoiceState } from 'discord-api-types/v10';
2
2
  import { GuildBasedResource } from './default/guild-based';
3
3
  export declare class VoiceStates extends GuildBasedResource<VoiceStateResource> {
4
4
  namespace: string;
@@ -1,14 +1,16 @@
1
1
  import { ApiHandler } from '../api';
2
2
  import type { Adapter } from '../cache';
3
3
  import { Cache } from '../cache';
4
- import type { RegisteredMiddlewares } from '../commands';
4
+ import type { Command, ContextMenuCommand, RegisteredMiddlewares } from '../commands';
5
5
  import type { InferWithPrefix, MiddlewareContext } from '../commands/applications/shared';
6
- import { CommandHandler } from '../commands/handler';
7
- import { ChannelShorter, EmojiShorter, GuildShorter, Logger, MemberShorter, MessageShorter, ReactionShorter, RoleShorter, TemplateShorter, UsersShorter, WebhookShorter, type LocaleString, type MakeRequired } from '../common';
6
+ import { type CommandHandlerLike } from '../commands/handler';
7
+ import { ChannelShorter, EmojiShorter, GuildShorter, Logger, MemberShorter, MessageShorter, ReactionShorter, RoleShorter, TemplateShorter, UsersShorter, WebhookShorter, type MakeRequired } from '../common';
8
+ import type { LocaleString } from 'discord-api-types/rest/v10';
8
9
  import type { DeepPartial, IntentStrings, OmitInsert, When } from '../common/types/util';
9
- import { ComponentHandler } from '../components/handler';
10
- import { LangsHandler } from '../langs/handler';
11
- import type { ChatInputCommandInteraction, Message, MessageCommandInteraction, UserCommandInteraction } from '../structures';
10
+ import type { ComponentCommand, ModalCommand } from '../components';
11
+ import { type ComponentHandlerLike } from '../components/handler';
12
+ import { type LangsHandlerLike } from '../langs/handler';
13
+ import type { ChatInputCommandInteraction, ComponentInteraction, Message, MessageCommandInteraction, UserCommandInteraction } from '../structures';
12
14
  export declare class BaseClient {
13
15
  rest: ApiHandler;
14
16
  cache: Cache;
@@ -24,9 +26,9 @@ export declare class BaseClient {
24
26
  emojis: EmojiShorter;
25
27
  debugger?: Logger;
26
28
  logger: Logger;
27
- langs: LangsHandler;
28
- commands: CommandHandler;
29
- components: ComponentHandler;
29
+ langs?: LangsHandlerLike;
30
+ commands?: CommandHandlerLike;
31
+ components?: ComponentHandlerLike;
30
32
  private _applicationId?;
31
33
  private _botId?;
32
34
  middlewares?: Record<string, MiddlewareContext>;
@@ -39,7 +41,7 @@ export declare class BaseClient {
39
41
  set applicationId(id: string);
40
42
  get applicationId(): string;
41
43
  get proxy(): import("../api").APIRoutes;
42
- setServices({ rest, cache, langs, middlewares }: ServicesOptions): void;
44
+ setServices({ rest, cache, langs, middlewares, handlers }: ServicesOptions): void;
43
45
  protected execute(..._options: unknown[]): Promise<void>;
44
46
  start(options?: Pick<DeepPartial<StartOptions>, 'langsDir' | 'commandsDir' | 'connection' | 'token' | 'componentsDir'>): Promise<void>;
45
47
  protected onPacket(..._packet: unknown[]): Promise<void>;
@@ -63,7 +65,7 @@ export declare class BaseClient {
63
65
  }>;
64
66
  }
65
67
  export interface BaseClientOptions {
66
- context?: (interaction: ChatInputCommandInteraction<boolean> | UserCommandInteraction<boolean> | MessageCommandInteraction<boolean> | When<InferWithPrefix, Message, never>) => {};
68
+ context?: (interaction: ChatInputCommandInteraction<boolean> | UserCommandInteraction<boolean> | MessageCommandInteraction<boolean> | ComponentInteraction | When<InferWithPrefix, Message, never>) => {};
67
69
  globalMiddlewares?: readonly (keyof RegisteredMiddlewares)[];
68
70
  }
69
71
  export interface StartOptions {
@@ -107,7 +109,7 @@ export type RuntimeConfigHTTP = Omit<MakeRequired<RC, 'publicKey' | 'application
107
109
  };
108
110
  export type InternalRuntimeConfig = Omit<MakeRequired<RC, 'intents'>, 'publicKey' | 'port'>;
109
111
  export type RuntimeConfig = OmitInsert<InternalRuntimeConfig, 'intents', {
110
- intents?: IntentStrings | number;
112
+ intents?: IntentStrings | number[] | number;
111
113
  }>;
112
114
  export interface ServicesOptions {
113
115
  rest?: ApiHandler;
@@ -120,5 +122,10 @@ export interface ServicesOptions {
120
122
  aliases?: Record<string, LocaleString[]>;
121
123
  };
122
124
  middlewares?: Record<string, MiddlewareContext>;
125
+ handlers?: {
126
+ components?: ComponentHandlerLike | ((component: ComponentCommand | ModalCommand) => any);
127
+ commands?: CommandHandlerLike | ((command: Command | ContextMenuCommand) => any);
128
+ langs?: LangsHandlerLike | ((locale: string, record: Record<string, unknown>) => any);
129
+ };
123
130
  }
124
131
  export {};
@@ -58,22 +58,60 @@ class BaseClient {
58
58
  get proxy() {
59
59
  return new api_1.Router(this.rest).createProxy();
60
60
  }
61
- setServices({ rest, cache, langs, middlewares }) {
61
+ setServices({ rest, cache, langs, middlewares, handlers }) {
62
62
  if (rest) {
63
63
  this.rest = rest;
64
64
  }
65
65
  if (cache) {
66
66
  this.cache = new cache_1.Cache(this.cache?.intents ?? 0, cache?.adapter ?? this.cache?.adapter ?? new cache_1.MemoryAdapter(), cache.disabledCache ?? this.cache?.disabledCache ?? [], this);
67
67
  }
68
+ if (middlewares) {
69
+ this.middlewares = middlewares;
70
+ }
71
+ if (handlers) {
72
+ if ('components' in handlers) {
73
+ if (!handlers.components) {
74
+ this.components = undefined;
75
+ }
76
+ else if (typeof handlers.components === 'function') {
77
+ this.components = new handler_2.ComponentHandler(this.logger, this);
78
+ this.components.__callback = handlers.components;
79
+ }
80
+ else {
81
+ this.components = handlers.components;
82
+ }
83
+ }
84
+ if ('commands' in handlers) {
85
+ if (!handlers.commands) {
86
+ this.commands = undefined;
87
+ }
88
+ else if (typeof handlers.commands === 'function') {
89
+ this.commands = new handler_1.CommandHandler(this.logger, this);
90
+ this.commands.__callback = handlers.commands;
91
+ }
92
+ else {
93
+ this.commands = handlers.commands;
94
+ }
95
+ }
96
+ if ('langs' in handlers) {
97
+ if (!handlers.langs) {
98
+ this.langs = undefined;
99
+ }
100
+ else if (typeof handlers.langs === 'function') {
101
+ this.langs = new handler_3.LangsHandler(this.logger);
102
+ this.langs.__callback = handlers.langs;
103
+ }
104
+ else {
105
+ this.langs = handlers.langs;
106
+ }
107
+ }
108
+ }
68
109
  if (langs) {
69
110
  if (langs.default)
70
111
  this.langs.defaultLang = langs.default;
71
112
  if (langs.aliases)
72
113
  this.langs.aliases = Object.entries(langs.aliases);
73
114
  }
74
- if (middlewares) {
75
- this.middlewares = middlewares;
76
- }
77
115
  }
78
116
  async execute(..._options) {
79
117
  if ((await this.getRC()).debug) {
@@ -139,21 +177,21 @@ class BaseClient {
139
177
  }
140
178
  async loadCommands(dir) {
141
179
  dir ??= await this.getRC().then(x => x.commands);
142
- if (dir) {
180
+ if (dir && this.commands) {
143
181
  await this.commands.load(dir, this);
144
182
  this.logger.info('CommandHandler loaded');
145
183
  }
146
184
  }
147
185
  async loadComponents(dir) {
148
186
  dir ??= await this.getRC().then(x => x.components);
149
- if (dir) {
187
+ if (dir && this.components) {
150
188
  await this.components.load(dir);
151
189
  this.logger.info('ComponentHandler loaded');
152
190
  }
153
191
  }
154
192
  async loadLangs(dir) {
155
193
  dir ??= await this.getRC().then(x => x.langs);
156
- if (dir) {
194
+ if (dir && this.langs) {
157
195
  await this.langs.load(dir);
158
196
  this.logger.info('LangsHandler loaded');
159
197
  }
@@ -1,6 +1,6 @@
1
- import type { Command, CommandContext, Message, SubCommand } from '..';
2
- import { type DeepPartial, type GatewayDispatchPayload, type GatewayPresenceUpdateData, type If } from '../common';
3
- import { EventHandler } from '../events';
1
+ import { type GatewayDispatchPayload, type GatewayPresenceUpdateData } from 'discord-api-types/v10';
2
+ import type { ClientEvent, Command, CommandContext, EventHandlerLike, Message, SubCommand } from '..';
3
+ import type { DeepPartial, If } from '../common';
4
4
  import { ClientUser } from '../structures';
5
5
  import { ShardManager, type ShardManagerOptions } from '../websocket';
6
6
  import { MemberUpdateHandler } from '../websocket/discord/events/memberUpdate';
@@ -10,7 +10,7 @@ import { BaseClient } from './base';
10
10
  export declare class Client<Ready extends boolean = boolean> extends BaseClient {
11
11
  private __handleGuilds?;
12
12
  gateway: ShardManager;
13
- events: EventHandler;
13
+ events?: EventHandlerLike;
14
14
  me: If<Ready, ClientUser>;
15
15
  options: ClientOptions | undefined;
16
16
  memberUpdateHandler: MemberUpdateHandler;
@@ -18,6 +18,9 @@ export declare class Client<Ready extends boolean = boolean> extends BaseClient
18
18
  constructor(options?: ClientOptions);
19
19
  setServices({ gateway, ...rest }: ServicesOptions & {
20
20
  gateway?: ShardManager;
21
+ handlers?: ServicesOptions['handlers'] & {
22
+ events?: EventHandlerLike | ((event: ClientEvent) => any);
23
+ };
21
24
  }): void;
22
25
  loadEvents(dir?: string): Promise<void>;
23
26
  protected execute(options?: {
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Client = void 0;
4
+ const v10_1 = require("discord-api-types/v10");
4
5
  const node_worker_threads_1 = require("node:worker_threads");
5
- const common_1 = require("../common");
6
6
  const events_1 = require("../events");
7
7
  const structures_1 = require("../structures");
8
8
  const websocket_1 = require("../websocket");
@@ -32,10 +32,22 @@ class Client extends base_1.BaseClient {
32
32
  };
33
33
  this.gateway = gateway;
34
34
  }
35
+ if (rest.handlers && 'events' in rest.handlers) {
36
+ if (!rest.handlers.events) {
37
+ this.events = undefined;
38
+ }
39
+ else if (typeof rest.handlers.events === 'function') {
40
+ this.events = new events_1.EventHandler(this.logger);
41
+ this.events.__callback = rest.handlers.events;
42
+ }
43
+ else {
44
+ this.events = rest.handlers.events;
45
+ }
46
+ }
35
47
  }
36
48
  async loadEvents(dir) {
37
49
  dir ??= await this.getRC().then(x => x.events);
38
- if (dir) {
50
+ if (dir && this.events) {
39
51
  await this.events.load(dir);
40
52
  this.logger.info('EventHandler loaded');
41
53
  }
@@ -92,21 +104,21 @@ class Client extends base_1.BaseClient {
92
104
  }
93
105
  }
94
106
  async onPacket(shardId, packet) {
95
- await this.events.runEvent('RAW', this, packet, shardId);
107
+ await this.events?.runEvent('RAW', this, packet, shardId);
96
108
  switch (packet.t) {
97
109
  //// Cases where we must obtain the old data before updating
98
110
  case 'GUILD_MEMBER_UPDATE':
99
111
  if (!this.memberUpdateHandler.check(packet.d)) {
100
112
  return;
101
113
  }
102
- await this.events.execute(packet.t, packet, this, shardId);
114
+ await this.events?.execute(packet.t, packet, this, shardId);
103
115
  await this.cache.onPacket(packet);
104
116
  break;
105
117
  case 'PRESENCE_UPDATE':
106
118
  if (!this.presenceUpdateHandler.check(packet.d)) {
107
119
  return;
108
120
  }
109
- await this.events.execute(packet.t, packet, this, shardId);
121
+ await this.events?.execute(packet.t, packet, this, shardId);
110
122
  await this.cache.onPacket(packet);
111
123
  break;
112
124
  //rest of the events
@@ -127,9 +139,9 @@ class Client extends base_1.BaseClient {
127
139
  this.applicationId = packet.d.application.id;
128
140
  this.me = new structures_1.ClientUser(this, packet.d.user, packet.d.application);
129
141
  if (!this.__handleGuilds?.size ||
130
- !((this.gateway.options.intents & common_1.GatewayIntentBits.Guilds) === common_1.GatewayIntentBits.Guilds)) {
142
+ !((this.gateway.options.intents & v10_1.GatewayIntentBits.Guilds) === v10_1.GatewayIntentBits.Guilds)) {
131
143
  if ([...this.gateway.values()].every(shard => shard.data.session_id)) {
132
- await this.events.runEvent('BOT_READY', this, this.me, -1);
144
+ await this.events?.runEvent('BOT_READY', this, this.me, -1);
133
145
  }
134
146
  delete this.__handleGuilds;
135
147
  }
@@ -139,7 +151,7 @@ class Client extends base_1.BaseClient {
139
151
  if (this.__handleGuilds?.has(packet.d.id)) {
140
152
  this.__handleGuilds.delete(packet.d.id);
141
153
  if (!this.__handleGuilds.size && [...this.gateway.values()].every(shard => shard.data.session_id)) {
142
- await this.events.runEvent('BOT_READY', this, this.me, -1);
154
+ await this.events?.runEvent('BOT_READY', this, this.me, -1);
143
155
  }
144
156
  if (!this.__handleGuilds.size)
145
157
  delete this.__handleGuilds;
@@ -148,7 +160,7 @@ class Client extends base_1.BaseClient {
148
160
  break;
149
161
  }
150
162
  }
151
- await this.events.execute(packet.t, packet, this, shardId);
163
+ await this.events?.execute(packet.t, packet, this, shardId);
152
164
  break;
153
165
  }
154
166
  }
@@ -1,6 +1,7 @@
1
1
  /// <reference types="node" />
2
+ import { type APIInteraction } from 'discord-api-types/v10';
2
3
  import type { HttpRequest, HttpResponse } from 'uWebSockets.js';
3
- import type { APIInteraction, DeepPartial } from '../common';
4
+ import type { DeepPartial } from '../common';
4
5
  import type { BaseClientOptions, StartOptions } from './base';
5
6
  import { BaseClient } from './base';
6
7
  export declare class HttpClient extends BaseClient {
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HttpClient = void 0;
4
+ const v10_1 = require("discord-api-types/v10");
4
5
  const magic_bytes_js_1 = require("magic-bytes.js");
5
6
  const api_1 = require("../api");
6
7
  const utils_1 = require("../api/utils/utils");
7
- const common_1 = require("../common");
8
8
  const base_1 = require("./base");
9
9
  const oninteractioncreate_1 = require("./oninteractioncreate");
10
10
  let UWS;
@@ -104,11 +104,11 @@ class HttpClient extends base_1.BaseClient {
104
104
  }
105
105
  else {
106
106
  switch (rawBody.type) {
107
- case common_1.InteractionType.Ping:
107
+ case v10_1.InteractionType.Ping:
108
108
  this.debugger?.debug('Ping interaction received, responding.');
109
109
  res
110
110
  .writeHeader('Content-Type', 'application/json')
111
- .end(JSON.stringify({ type: common_1.InteractionResponseType.Pong }));
111
+ .end(JSON.stringify({ type: v10_1.InteractionResponseType.Pong }));
112
112
  break;
113
113
  default:
114
114
  await (0, oninteractioncreate_1.onInteractionCreate)(this, rawBody, -1, async ({ body, files }) => {
@@ -9,13 +9,13 @@ async function onInteractionCreate(self, body, shardId, __reply) {
9
9
  switch (body.type) {
10
10
  case v10_1.InteractionType.ApplicationCommandAutocomplete:
11
11
  {
12
- const parentCommand = self.commands.values.find(x => {
13
- if (x.guild_id && !x.guild_id.includes(body.data.guild_id ?? '')) {
14
- return false;
12
+ const parentCommand = self.commands?.values.find(x => {
13
+ if (body.data.guild_id) {
14
+ return x.guild_id?.includes(body.data.guild_id) && x.name === body.data.name;
15
15
  }
16
16
  return x.name === body.data.name;
17
17
  });
18
- const optionsResolver = new commands_1.OptionResolver(self, body.data.options ?? [], parentCommand, body.data.guild_id, body.data.resolved);
18
+ const optionsResolver = new commands_1.OptionResolver(self, body.data.options ?? [], parentCommand, body.guild_id, body.data.resolved);
19
19
  const interaction = new structures_1.AutocompleteInteraction(self, body, __reply);
20
20
  const command = optionsResolver.getAutocomplete();
21
21
  // idc, is a YOU problem
@@ -47,9 +47,9 @@ async function onInteractionCreate(self, body, shardId, __reply) {
47
47
  case v10_1.ApplicationCommandType.Message:
48
48
  case v10_1.ApplicationCommandType.User:
49
49
  {
50
- const command = self.commands.values.find(x => {
51
- if (x.guild_id && !x.guild_id.includes(body.data.guild_id ?? '')) {
52
- return false;
50
+ const command = self.commands?.values.find(x => {
51
+ if (body.data.guild_id) {
52
+ return x.guild_id?.includes(body.data.guild_id) && x.name === body.data.name;
53
53
  }
54
54
  return x.name === body.data.name;
55
55
  });
@@ -62,7 +62,7 @@ async function onInteractionCreate(self, body, shardId, __reply) {
62
62
  Object.assign(context, extendContext);
63
63
  try {
64
64
  if (command.botPermissions && interaction.appPermissions) {
65
- const permissions = interaction.appPermissions.missings(...interaction.appPermissions.values(command.botPermissions));
65
+ const permissions = interaction.appPermissions.missings(...interaction.appPermissions.values([command.botPermissions]));
66
66
  if (permissions.length) {
67
67
  return command.onPermissionsFail?.(context, interaction.appPermissions.keys(permissions));
68
68
  }
@@ -102,14 +102,13 @@ async function onInteractionCreate(self, body, shardId, __reply) {
102
102
  break;
103
103
  case v10_1.ApplicationCommandType.ChatInput:
104
104
  {
105
- const packetData = body.data;
106
- const parentCommand = self.commands.values.find(x => {
107
- if (x.guild_id && !x.guild_id.includes(packetData.guild_id ?? '')) {
108
- return false;
105
+ const parentCommand = self.commands?.values.find(x => {
106
+ if (body.data.guild_id) {
107
+ return x.guild_id?.includes(body.data.guild_id) && x.name === body.data.name;
109
108
  }
110
- return x.name === packetData.name;
109
+ return x.name === body.data.name;
111
110
  });
112
- const optionsResolver = new commands_1.OptionResolver(self, packetData.options ?? [], parentCommand, packetData.guild_id, packetData.resolved);
111
+ const optionsResolver = new commands_1.OptionResolver(self, body.data.options ?? [], parentCommand, body.guild_id, body.data.resolved);
113
112
  const interaction = structures_1.BaseInteraction.from(self, body, __reply);
114
113
  const command = optionsResolver.getCommand();
115
114
  if (!command?.run)
@@ -119,7 +118,7 @@ async function onInteractionCreate(self, body, shardId, __reply) {
119
118
  Object.assign(context, extendContext);
120
119
  try {
121
120
  if (command.botPermissions && interaction.appPermissions) {
122
- const permissions = interaction.appPermissions.missings(...interaction.appPermissions.values(command.botPermissions));
121
+ const permissions = interaction.appPermissions.missings(...interaction.appPermissions.values([command.botPermissions]));
123
122
  if (permissions.length) {
124
123
  return command.onPermissionsFail?.(context, interaction.appPermissions.keys(permissions));
125
124
  }
@@ -167,22 +166,22 @@ async function onInteractionCreate(self, body, shardId, __reply) {
167
166
  case v10_1.InteractionType.ModalSubmit:
168
167
  {
169
168
  const interaction = structures_1.BaseInteraction.from(self, body, __reply);
170
- if (self.components.hasModal(interaction)) {
169
+ if (self.components?.hasModal(interaction)) {
171
170
  await self.components.onModalSubmit(interaction);
172
171
  }
173
172
  else {
174
- await self.components.executeModal(interaction);
173
+ await self.components?.executeModal(interaction);
175
174
  }
176
175
  }
177
176
  break;
178
177
  case v10_1.InteractionType.MessageComponent:
179
178
  {
180
179
  const interaction = structures_1.BaseInteraction.from(self, body, __reply);
181
- if (self.components.hasComponent(body.message.id, interaction.customId)) {
180
+ if (self.components?.hasComponent(body.message.id, interaction.customId)) {
182
181
  await self.components.onComponent(body.message.id, interaction);
183
182
  }
184
183
  else {
185
- await self.components.executeComponent(interaction);
184
+ await self.components?.executeComponent(interaction);
186
185
  }
187
186
  }
188
187
  break;
@@ -45,13 +45,15 @@ async function onMessageCreate(self, rawMessage, shardId) {
45
45
  if (!prefix || !message.content.startsWith(prefix))
46
46
  return;
47
47
  const content = message.content.slice(prefix.length).trimStart();
48
- const { fullCommandName, command, parent } = getCommandFromContent(content.split(' ').filter(x => x), self);
48
+ const { fullCommandName, command, parent } = getCommandFromContent(content
49
+ .split(' ')
50
+ .filter(x => x)
51
+ .slice(0, 3), self);
49
52
  if (!command)
50
53
  return;
51
54
  if (!command.run)
52
55
  return self.logger.warn(`${fullCommandName} command does not have 'run' callback`);
53
- if ([__1.InteractionContextTypes.BOT_DM, __1.InteractionContextTypes.PRIVATE_CHANNEL].some(i => command.contexts?.includes(i)) &&
54
- !message.guildId)
56
+ if (!command.contexts?.includes(__1.InteractionContextTypes.BOT_DM) && !message.guildId)
55
57
  return;
56
58
  if (command.guild_id && !command.guild_id?.includes(message.guildId))
57
59
  return;
@@ -75,7 +77,7 @@ async function onMessageCreate(self, rawMessage, shardId) {
75
77
  if (!meMember)
76
78
  return; //enable member cache and "Guilds" intent, lol
77
79
  const appPermissions = await meMember.fetchPermissions();
78
- const permissions = appPermissions.missings(...appPermissions.values(command.botPermissions));
80
+ const permissions = appPermissions.missings(...appPermissions.values([command.botPermissions]));
79
81
  if (permissions.length) {
80
82
  return command.onPermissionsFail?.(context, appPermissions.keys(permissions));
81
83
  }