seyfert 0.1.0 → 1.0.1

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 (198) hide show
  1. package/README.md +19 -30
  2. package/lib/api/CDN.d.ts +0 -8
  3. package/lib/api/CDN.js +7 -13
  4. package/lib/api/Router.d.ts +2 -2
  5. package/lib/api/Router.js +1 -1
  6. package/lib/api/Routes/applications.d.ts +1 -1
  7. package/lib/api/Routes/channels.d.ts +1 -1
  8. package/lib/api/Routes/gateway.d.ts +1 -1
  9. package/lib/api/Routes/guilds.d.ts +1 -1
  10. package/lib/api/Routes/interactions.d.ts +1 -1
  11. package/lib/api/Routes/invites.d.ts +1 -1
  12. package/lib/api/Routes/stage-instances.d.ts +1 -1
  13. package/lib/api/Routes/stickers.d.ts +1 -1
  14. package/lib/api/Routes/users.d.ts +1 -1
  15. package/lib/api/Routes/voice.d.ts +1 -1
  16. package/lib/api/Routes/webhooks.d.ts +1 -1
  17. package/lib/api/api.d.ts +44 -0
  18. package/lib/api/api.js +354 -0
  19. package/lib/api/bucket.d.ts +19 -0
  20. package/lib/api/bucket.js +71 -0
  21. package/lib/api/index.d.ts +1 -1
  22. package/lib/api/index.js +1 -1
  23. package/lib/api/shared.d.ts +33 -5
  24. package/lib/api/shared.js +2 -7
  25. package/lib/api/utils/constants.d.ts +1 -30
  26. package/lib/api/utils/constants.js +2 -41
  27. package/lib/api/utils/types.d.ts +1 -320
  28. package/lib/api/utils/utils.d.ts +0 -38
  29. package/lib/api/utils/utils.js +1 -139
  30. package/lib/builders/ActionRow.js +1 -1
  31. package/lib/builders/Attachment.d.ts +14 -6
  32. package/lib/builders/Attachment.js +30 -7
  33. package/lib/builders/Button.d.ts +5 -14
  34. package/lib/builders/Button.js +0 -11
  35. package/lib/builders/{MessageEmbed.d.ts → Embed.d.ts} +15 -15
  36. package/lib/builders/{MessageEmbed.js → Embed.js} +16 -16
  37. package/lib/builders/Modal.js +1 -1
  38. package/lib/builders/SelectMenu.d.ts +14 -15
  39. package/lib/builders/SelectMenu.js +19 -18
  40. package/lib/builders/index.d.ts +1 -1
  41. package/lib/builders/index.js +1 -1
  42. package/lib/builders/types.d.ts +2 -2
  43. package/lib/cache/adapters/default.d.ts +1 -0
  44. package/lib/cache/adapters/default.js +3 -2
  45. package/lib/cache/adapters/redis.d.ts +3 -3
  46. package/lib/cache/adapters/redis.js +14 -5
  47. package/lib/cache/adapters/types.d.ts +1 -0
  48. package/lib/cache/adapters/workeradapter.d.ts +10 -1
  49. package/lib/cache/adapters/workeradapter.js +8 -3
  50. package/lib/cache/index.d.ts +18 -5
  51. package/lib/cache/index.js +23 -9
  52. package/lib/cache/resources/channels.d.ts +6 -2
  53. package/lib/cache/resources/channels.js +12 -6
  54. package/lib/cache/resources/default/base.d.ts +17 -16
  55. package/lib/cache/resources/default/base.js +25 -24
  56. package/lib/cache/resources/default/guild-based.d.ts +22 -19
  57. package/lib/cache/resources/default/guild-based.js +32 -31
  58. package/lib/cache/resources/default/guild-related.d.ts +22 -19
  59. package/lib/cache/resources/default/guild-related.js +37 -43
  60. package/lib/cache/resources/emojis.d.ts +4 -2
  61. package/lib/cache/resources/emojis.js +8 -6
  62. package/lib/cache/resources/guilds.d.ts +4 -2
  63. package/lib/cache/resources/guilds.js +15 -8
  64. package/lib/cache/resources/members.d.ts +4 -2
  65. package/lib/cache/resources/members.js +16 -13
  66. package/lib/cache/resources/overwrites.d.ts +25 -0
  67. package/lib/cache/resources/overwrites.js +39 -0
  68. package/lib/cache/resources/presence.js +3 -4
  69. package/lib/cache/resources/roles.d.ts +4 -2
  70. package/lib/cache/resources/roles.js +8 -6
  71. package/lib/cache/resources/stickers.d.ts +4 -2
  72. package/lib/cache/resources/stickers.js +8 -6
  73. package/lib/cache/resources/threads.d.ts +4 -2
  74. package/lib/cache/resources/threads.js +8 -6
  75. package/lib/cache/resources/users.d.ts +4 -2
  76. package/lib/cache/resources/users.js +8 -6
  77. package/lib/cache/resources/voice-states.d.ts +3 -3
  78. package/lib/cache/resources/voice-states.js +6 -7
  79. package/lib/client/base.d.ts +48 -16
  80. package/lib/client/base.js +19 -15
  81. package/lib/client/client.d.ts +15 -4
  82. package/lib/client/client.js +26 -28
  83. package/lib/client/httpclient.d.ts +3 -5
  84. package/lib/client/httpclient.js +29 -16
  85. package/lib/client/{oninteraction.d.ts → oninteractioncreate.d.ts} +1 -1
  86. package/lib/client/{oninteraction.js → oninteractioncreate.js} +34 -23
  87. package/lib/client/onmessagecreate.d.ts +3 -0
  88. package/lib/client/onmessagecreate.js +337 -0
  89. package/lib/client/workerclient.d.ts +19 -2
  90. package/lib/client/workerclient.js +156 -46
  91. package/lib/collection.d.ts +1 -1
  92. package/lib/collection.js +9 -6
  93. package/lib/commands/applications/chat.d.ts +32 -25
  94. package/lib/commands/applications/chat.js +51 -34
  95. package/lib/commands/applications/chatcontext.d.ts +34 -16
  96. package/lib/commands/applications/chatcontext.js +99 -20
  97. package/lib/commands/applications/menu.d.ts +9 -8
  98. package/lib/commands/applications/menu.js +14 -5
  99. package/lib/commands/applications/menucontext.d.ts +27 -10
  100. package/lib/commands/applications/menucontext.js +51 -7
  101. package/lib/commands/applications/options.d.ts +13 -13
  102. package/lib/commands/applications/shared.d.ts +7 -2
  103. package/lib/commands/decorators.d.ts +14 -14
  104. package/lib/commands/decorators.js +9 -5
  105. package/lib/commands/handler.d.ts +2 -1
  106. package/lib/commands/handler.js +60 -14
  107. package/lib/commands/index.d.ts +1 -1
  108. package/lib/commands/index.js +2 -1
  109. package/lib/commands/optionresolver.d.ts +6 -5
  110. package/lib/commands/optionresolver.js +10 -6
  111. package/lib/common/bot/watcher.d.ts +3 -3
  112. package/lib/common/bot/watcher.js +3 -1
  113. package/lib/common/index.d.ts +1 -1
  114. package/lib/common/index.js +2 -1
  115. package/lib/common/it/logger.d.ts +11 -0
  116. package/lib/common/it/logger.js +51 -2
  117. package/lib/common/it/utils.d.ts +3 -13
  118. package/lib/common/it/utils.js +9 -30
  119. package/lib/common/shorters/channels.d.ts +55 -5
  120. package/lib/common/shorters/channels.js +59 -0
  121. package/lib/common/shorters/guilds.d.ts +5 -2
  122. package/lib/common/shorters/guilds.js +18 -0
  123. package/lib/common/shorters/messages.js +0 -2
  124. package/lib/common/shorters/overwrites.d.ts +29 -0
  125. package/lib/common/shorters/overwrites.js +63 -0
  126. package/lib/common/shorters/roles.js +3 -3
  127. package/lib/common/shorters/webhook.d.ts +2 -2
  128. package/lib/common/types/util.d.ts +3 -2
  129. package/lib/common/types/write.d.ts +3 -7
  130. package/lib/components/handler.d.ts +11 -17
  131. package/lib/components/handler.js +45 -93
  132. package/lib/components/index.d.ts +0 -1
  133. package/lib/components/index.js +0 -1
  134. package/lib/components/listener.d.ts +2 -2
  135. package/lib/components/listener.js +2 -3
  136. package/lib/events/event.d.ts +2 -2
  137. package/lib/events/handler.d.ts +3 -2
  138. package/lib/events/handler.js +14 -6
  139. package/lib/events/hooks/dispatch.d.ts +2 -1
  140. package/lib/events/hooks/dispatch.js +5 -1
  141. package/lib/events/hooks/thread.d.ts +63 -63
  142. package/lib/index.d.ts +8 -5
  143. package/lib/index.js +20 -10
  144. package/lib/langs/handler.d.ts +6 -4
  145. package/lib/langs/handler.js +10 -8
  146. package/lib/langs/router.d.ts +8 -9
  147. package/lib/langs/router.js +5 -5
  148. package/lib/structures/ClientUser.d.ts +1 -16
  149. package/lib/structures/ClientUser.js +0 -31
  150. package/lib/structures/Guild.d.ts +1 -1
  151. package/lib/structures/GuildMember.d.ts +12 -0
  152. package/lib/structures/GuildMember.js +14 -0
  153. package/lib/structures/GuildRole.d.ts +4 -2
  154. package/lib/structures/GuildRole.js +4 -1
  155. package/lib/structures/GuildTemplate.js +1 -1
  156. package/lib/structures/Interaction.d.ts +2 -0
  157. package/lib/structures/Interaction.js +12 -13
  158. package/lib/structures/Message.d.ts +7 -2
  159. package/lib/structures/Message.js +6 -3
  160. package/lib/structures/Sticker.d.ts +1 -1
  161. package/lib/structures/Sticker.js +1 -1
  162. package/lib/structures/User.d.ts +5 -0
  163. package/lib/structures/User.js +3 -0
  164. package/lib/structures/Webhook.d.ts +1 -1
  165. package/lib/structures/Webhook.js +1 -1
  166. package/lib/structures/channels.d.ts +45 -6
  167. package/lib/structures/channels.js +23 -7
  168. package/lib/structures/extra/BitField.d.ts +9 -6
  169. package/lib/structures/extra/BitField.js +27 -3
  170. package/lib/structures/extra/Permissions.d.ts +6 -1
  171. package/lib/structures/extra/Permissions.js +7 -0
  172. package/lib/websocket/constants/index.js +1 -3
  173. package/lib/websocket/discord/basesocket.js +0 -1
  174. package/lib/websocket/discord/shared.d.ts +2 -0
  175. package/lib/websocket/discord/worker.d.ts +23 -7
  176. package/lib/websocket/discord/workermanager.d.ts +32 -5
  177. package/lib/websocket/discord/workermanager.js +98 -29
  178. package/package.json +23 -21
  179. package/lib/api/REST.d.ts +0 -127
  180. package/lib/api/REST.js +0 -424
  181. package/lib/api/errors/DiscordAPIError.d.ts +0 -51
  182. package/lib/api/errors/DiscordAPIError.js +0 -81
  183. package/lib/api/errors/HTTPError.d.ts +0 -20
  184. package/lib/api/errors/HTTPError.js +0 -28
  185. package/lib/api/errors/RateLimitError.d.ts +0 -19
  186. package/lib/api/errors/RateLimitError.js +0 -37
  187. package/lib/api/handlers/BurstHandler.d.ts +0 -51
  188. package/lib/api/handlers/BurstHandler.js +0 -124
  189. package/lib/api/handlers/SequentialHandler.d.ts +0 -81
  190. package/lib/api/handlers/SequentialHandler.js +0 -365
  191. package/lib/api/handlers/Shared.d.ts +0 -14
  192. package/lib/api/handlers/Shared.js +0 -125
  193. package/lib/api/interfaces/Handler.d.ts +0 -21
  194. package/lib/api/interfaces/Handler.js +0 -2
  195. package/lib/websocket/discord/handlemessage.d.ts +0 -0
  196. package/lib/websocket/discord/handlemessage.js +0 -1
  197. package/lib/websocket/discord/memberUpdate.d.ts +0 -16
  198. package/lib/websocket/discord/memberUpdate.js +0 -47
@@ -1,9 +1,12 @@
1
- import { type InteractionCreateBodyRequest, type InteractionMessageUpdateBodyRequest, type ModalCreateBodyRequest, type UnionToTuple } from '../../common';
2
- import { Message, User, type MessageCommandInteraction, type UserCommandInteraction } from '../../structures';
1
+ import { CommandContext, type ReturnCache, type WebhookMessage } from '../..';
2
+ import { type InteractionCreateBodyRequest, type InteractionMessageUpdateBodyRequest, type UnionToTuple, type When } from '../../common';
3
+ import { Message, User, type AllChannels, type Guild, type GuildMember, type MessageCommandInteraction, type UserCommandInteraction } from '../../structures';
3
4
  import type { RegisteredMiddlewares } from '../decorators';
4
- import type { CommandMetadata, DefaultLocale, ExtendContext, GlobalMetadata, UsingClient } from './shared';
5
+ import type { CommandMetadata, ExtendContext, GlobalMetadata, UsingClient } from './shared';
5
6
  export type InteractionTarget<T> = T extends MessageCommandInteraction ? Message : User;
6
- export declare class MenuCommandContext<T extends MessageCommandInteraction | UserCommandInteraction, M extends keyof RegisteredMiddlewares = never> implements ExtendContext {
7
+ export interface MenuCommandContext<T extends MessageCommandInteraction | UserCommandInteraction, M extends keyof RegisteredMiddlewares = never> extends ExtendContext {
8
+ }
9
+ export declare class MenuCommandContext<T extends MessageCommandInteraction | UserCommandInteraction, M extends keyof RegisteredMiddlewares = never> {
7
10
  readonly client: UsingClient;
8
11
  readonly interaction: T;
9
12
  readonly shardId: number;
@@ -12,14 +15,28 @@ export declare class MenuCommandContext<T extends MessageCommandInteraction | Us
12
15
  globalMetadata: GlobalMetadata;
13
16
  get proxy(): import("../..").APIRoutes;
14
17
  get target(): InteractionTarget<T>;
15
- get t(): DefaultLocale;
16
- write(body: InteractionCreateBodyRequest): Promise<void>;
17
- modal(body: ModalCreateBodyRequest): Promise<void>;
18
+ get t(): import("../..").__InternalParseLocale<import("./shared").DefaultLocale> & {
19
+ get(locale?: string | undefined): import("./shared").DefaultLocale;
20
+ };
21
+ write<FR extends boolean = false>(body: InteractionCreateBodyRequest, fetchReply?: FR): Promise<When<FR, WebhookMessage, void | WebhookMessage>>;
22
+ get modal(): ((body: import("../../common").ModalCreateBodyRequest) => Promise<void>) | ((body: import("../../common").ModalCreateBodyRequest) => Promise<void>);
18
23
  deferReply(ephemeral?: boolean): Promise<void>;
19
24
  editResponse(body: InteractionMessageUpdateBodyRequest): Promise<Message>;
20
25
  deleteResponse(): Promise<void>;
21
- editOrReply(body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest): Promise<void>;
22
- fetchResponse(): Promise<import("../../structures").WebhookMessage | undefined>;
26
+ editOrReply<FR extends boolean = false>(body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest, fetchReply?: FR): Promise<When<FR, WebhookMessage | Message, void | WebhookMessage | Message>>;
27
+ fetchResponse(): Promise<WebhookMessage | undefined>;
28
+ channel(mode?: 'rest' | 'flow'): Promise<AllChannels>;
29
+ channel(mode?: 'cache'): ReturnCache<AllChannels>;
30
+ me(mode?: 'rest' | 'flow'): Promise<GuildMember>;
31
+ me(mode?: 'cache'): ReturnCache<GuildMember | undefined>;
32
+ guild(mode?: 'rest' | 'flow'): Promise<Guild<'cached' | 'api'> | undefined>;
33
+ guild(mode?: 'cache'): ReturnCache<Guild<'cached'> | undefined>;
34
+ get guildId(): string | undefined;
35
+ get channelId(): string;
23
36
  get author(): User;
24
- get member(): import("../../structures").InteractionGuildMember | undefined;
37
+ get member(): import("../..").InteractionGuildMember | undefined;
38
+ isChat(): this is CommandContext;
39
+ isMenu(): this is MenuCommandContext<any>;
40
+ isMenuUser(): this is MenuCommandContext<UserCommandInteraction>;
41
+ isMenuMessage(): this is MenuCommandContext<MessageCommandInteraction>;
25
42
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MenuCommandContext = void 0;
4
+ const __1 = require("../..");
4
5
  const common_1 = require("../../common");
5
6
  const structures_1 = require("../../structures");
6
7
  class MenuCommandContext {
@@ -17,7 +18,7 @@ class MenuCommandContext {
17
18
  get proxy() {
18
19
  return this.client.proxy;
19
20
  }
20
- // biome-ignore lint/suspicious/useGetterReturn: bugged
21
+ // biome-ignore lint/suspicious/useGetterReturn: default don't exist.
21
22
  get target() {
22
23
  switch (this.interaction.data.type) {
23
24
  case common_1.ApplicationCommandType.Message: {
@@ -33,11 +34,11 @@ class MenuCommandContext {
33
34
  get t() {
34
35
  return this.client.langs.get(this.interaction.locale);
35
36
  }
36
- write(body) {
37
- return this.interaction.write(body);
37
+ write(body, fetchReply) {
38
+ return this.interaction.write(body, fetchReply);
38
39
  }
39
- modal(body) {
40
- return this.interaction.modal(body);
40
+ get modal() {
41
+ return this.interaction.modal;
41
42
  }
42
43
  deferReply(ephemeral = false) {
43
44
  return this.interaction.deferReply(ephemeral ? common_1.MessageFlags.Ephemeral : undefined);
@@ -48,17 +49,60 @@ class MenuCommandContext {
48
49
  deleteResponse() {
49
50
  return this.interaction.deleteResponse();
50
51
  }
51
- editOrReply(body) {
52
- return this.interaction.editOrReply(body);
52
+ editOrReply(body, fetchReply) {
53
+ return this.interaction.editOrReply(body, fetchReply);
53
54
  }
54
55
  fetchResponse() {
55
56
  return this.interaction.fetchResponse();
56
57
  }
58
+ channel(mode = 'cache') {
59
+ if (this.interaction?.channel && mode === 'cache')
60
+ return this.client.cache.adapter.isAsync ? Promise.resolve(this.interaction.channel) : this.interaction.channel;
61
+ return this.client.channels.fetch(this.channelId, mode === 'rest');
62
+ }
63
+ me(mode = 'cache') {
64
+ if (!this.guildId)
65
+ return mode === 'cache' ? (this.client.cache.adapter.isAsync ? Promise.resolve() : undefined) : Promise.resolve();
66
+ switch (mode) {
67
+ case 'cache':
68
+ return this.client.cache.members?.get(this.client.botId, this.guildId);
69
+ default:
70
+ return this.client.members.fetch(this.guildId, this.client.botId, mode === 'rest');
71
+ }
72
+ }
73
+ guild(mode = 'cache') {
74
+ if (!this.guildId)
75
+ return (mode === 'cache' ? (this.client.cache.adapter.isAsync ? Promise.resolve() : undefined) : Promise.resolve());
76
+ switch (mode) {
77
+ case 'cache':
78
+ return this.client.cache.guilds?.get(this.guildId);
79
+ default:
80
+ return this.client.guilds.fetch(this.guildId, mode === 'rest');
81
+ }
82
+ }
83
+ get guildId() {
84
+ return this.interaction.guildId;
85
+ }
86
+ get channelId() {
87
+ return this.interaction.channelId;
88
+ }
57
89
  get author() {
58
90
  return this.interaction.user;
59
91
  }
60
92
  get member() {
61
93
  return this.interaction.member;
62
94
  }
95
+ isChat() {
96
+ return this instanceof __1.CommandContext;
97
+ }
98
+ isMenu() {
99
+ return this instanceof MenuCommandContext;
100
+ }
101
+ isMenuUser() {
102
+ return this instanceof MenuCommandContext && this.target instanceof structures_1.User;
103
+ }
104
+ isMenuMessage() {
105
+ return this instanceof MenuCommandContext && this.target instanceof structures_1.Message;
106
+ }
63
107
  }
64
108
  exports.MenuCommandContext = MenuCommandContext;
@@ -1,9 +1,10 @@
1
1
  import { ApplicationCommandOptionType, type APIApplicationCommandOptionChoice, type ChannelType } from 'discord-api-types/v10';
2
- import type { AutocompleteCallback, OnAutocompleteErrorCallback, ReturnOptionsTypes, __TypesWrapper } from '..';
2
+ import type { AutocompleteCallback, MenuCommandContext, OnAutocompleteErrorCallback, ReturnOptionsTypes, __TypesWrapper } from '..';
3
+ import type { MessageCommandInteraction, UserCommandInteraction } from '../../structures';
3
4
  import type { CommandContext } from './chatcontext';
4
5
  import type { MiddlewareContext } from './shared';
5
- type SeyfertBasicOption<T extends keyof __TypesWrapper, D = {}> = __TypesWrapper[T] & D;
6
- type SeyfertStringOption = SeyfertBasicOption<'String'> & {
6
+ export type SeyfertBasicOption<T extends keyof __TypesWrapper, D = {}> = __TypesWrapper[T] & D;
7
+ export type SeyfertStringOption = SeyfertBasicOption<'String'> & {
7
8
  autocomplete?: AutocompleteCallback;
8
9
  onAutocompleteError?: OnAutocompleteErrorCallback;
9
10
  choices?: readonly {
@@ -13,28 +14,28 @@ type SeyfertStringOption = SeyfertBasicOption<'String'> & {
13
14
  min_length?: number;
14
15
  max_length?: number;
15
16
  };
16
- type SeyfertIntegerOption = SeyfertBasicOption<'Integer'> & {
17
+ export type SeyfertIntegerOption = SeyfertBasicOption<'Integer'> & {
17
18
  autocomplete?: AutocompleteCallback;
18
19
  onAutocompleteError?: OnAutocompleteErrorCallback;
19
20
  choices?: APIApplicationCommandOptionChoice<ReturnOptionsTypes[ApplicationCommandOptionType.Integer]>[];
20
21
  min_value?: number;
21
22
  max_value?: number;
22
23
  };
23
- type SeyfertBooleanOption = SeyfertBasicOption<'Boolean'>;
24
- type SeyfertUserOption = SeyfertBasicOption<'User'>;
25
- type SeyfertChannelOption = SeyfertBasicOption<'Channel'> & {
24
+ export type SeyfertBooleanOption = SeyfertBasicOption<'Boolean'>;
25
+ export type SeyfertUserOption = SeyfertBasicOption<'User'>;
26
+ export type SeyfertChannelOption = SeyfertBasicOption<'Channel'> & {
26
27
  channel_types?: ChannelType[];
27
28
  };
28
- type SeyfertRoleOption = SeyfertBasicOption<'Role'>;
29
- type SeyfertMentionableOption = SeyfertBasicOption<'Mentionable'>;
30
- type SeyfertNumberOption = SeyfertBasicOption<'Number'> & {
29
+ export type SeyfertRoleOption = SeyfertBasicOption<'Role'>;
30
+ export type SeyfertMentionableOption = SeyfertBasicOption<'Mentionable'>;
31
+ export type SeyfertNumberOption = SeyfertBasicOption<'Number'> & {
31
32
  autocomplete?: AutocompleteCallback;
32
33
  onAutocompleteError?: OnAutocompleteErrorCallback;
33
34
  choices?: APIApplicationCommandOptionChoice<ReturnOptionsTypes[ApplicationCommandOptionType.Number]>[];
34
35
  min_value?: number;
35
36
  max_value?: number;
36
37
  };
37
- type SeyfertAttachmentOption = SeyfertBasicOption<'Attachment'>;
38
+ export type SeyfertAttachmentOption = SeyfertBasicOption<'Attachment'>;
38
39
  export declare function createStringOption<T extends SeyfertStringOption = SeyfertStringOption>(data: T): T & {
39
40
  readonly type: ApplicationCommandOptionType.String;
40
41
  };
@@ -62,6 +63,5 @@ export declare function createNumberOption<T extends SeyfertNumberOption = Seyfe
62
63
  export declare function createAttachmentOption<T extends SeyfertAttachmentOption = SeyfertAttachmentOption>(data: T): T & {
63
64
  readonly type: ApplicationCommandOptionType.Attachment;
64
65
  };
65
- export type ParseMiddlewareType<T> = T extends MiddlewareContext<any, CommandContext> ? T : MiddlewareContext<T, CommandContext>;
66
+ export type ParseMiddlewareType<T> = T extends MiddlewareContext<any, CommandContext | MenuCommandContext<MessageCommandInteraction<boolean> | UserCommandInteraction<boolean>>> ? T : MiddlewareContext<T, CommandContext | MenuCommandContext<MessageCommandInteraction<boolean> | UserCommandInteraction<boolean>>>;
66
67
  export declare function createMiddleware<T = ParseMiddlewareType<unknown>>(data: ParseMiddlewareType<T>): ParseMiddlewareType<T>;
67
- export {};
@@ -1,9 +1,12 @@
1
1
  import type { BaseClient } from '../../client/base';
2
2
  import type { RegisteredMiddlewares } from '../decorators';
3
3
  export type OKFunction<T> = (value: T) => void;
4
- export type StopFunction = (error: Error) => void;
4
+ export type StopFunction = (error: string) => void;
5
5
  export type NextFunction<T = unknown> = (data: T) => void;
6
6
  export type PassFunction = () => void;
7
+ export type InferWithPrefix = InternalOptions extends {
8
+ withPrefix: infer P;
9
+ } ? P : false;
7
10
  export interface GlobalMetadata {
8
11
  }
9
12
  export interface DefaultLocale {
@@ -13,6 +16,8 @@ export interface ExtendContext {
13
16
  export interface UsingClient extends BaseClient {
14
17
  }
15
18
  export type ParseClient<T extends BaseClient> = T;
19
+ export interface InternalOptions {
20
+ }
16
21
  export type MiddlewareContext<T = any, C = any> = (context: {
17
22
  context: C;
18
23
  next: NextFunction<T>;
@@ -31,5 +36,5 @@ export type OnOptionsReturnObject = Record<string, {
31
36
  value: unknown;
32
37
  } | {
33
38
  failed: true;
34
- value: Error;
39
+ value: string;
35
40
  }>;
@@ -1,12 +1,12 @@
1
- import { ApplicationCommandType, type LocaleString, type PermissionStrings } from '../common';
1
+ import { ApplicationCommandType, type FlatObjectKeys, type LocaleString, type PermissionStrings } from '../common';
2
2
  import type { CommandOption, OptionsRecord, SubCommand } from './applications/chat';
3
- import type { MiddlewareContext } from './applications/shared';
3
+ import type { DefaultLocale, MiddlewareContext } from './applications/shared';
4
4
  export interface RegisteredMiddlewares {
5
5
  }
6
6
  type DeclareOptions = {
7
7
  name: string;
8
8
  description: string;
9
- permissions?: PermissionStrings | bigint;
9
+ botPermissions?: PermissionStrings | bigint;
10
10
  defaultPermissions?: PermissionStrings | bigint;
11
11
  guildId?: string[];
12
12
  dm?: boolean;
@@ -14,7 +14,7 @@ type DeclareOptions = {
14
14
  } | (Omit<{
15
15
  name: string;
16
16
  description: string;
17
- permissions?: PermissionStrings | bigint;
17
+ botPermissions?: PermissionStrings | bigint;
18
18
  defaultPermissions?: PermissionStrings | bigint;
19
19
  guildId?: string[];
20
20
  dm?: boolean;
@@ -35,23 +35,23 @@ export declare function Locales({ name: names, description: descriptions, }: {
35
35
  } | undefined;
36
36
  };
37
37
  } & T;
38
- export declare function LocalesT(name: string, description: string): <T extends new (...args: any[]) => {}>(target: T) => {
38
+ export declare function LocalesT(name?: FlatObjectKeys<DefaultLocale>, description?: FlatObjectKeys<DefaultLocale>): <T extends new (...args: any[]) => {}>(target: T) => {
39
39
  new (...args: any[]): {
40
40
  __t: {
41
- name: string;
42
- description: string;
41
+ name: undefined;
42
+ description: undefined;
43
43
  };
44
44
  };
45
45
  } & T;
46
46
  export declare function GroupsT(groups: Record<string, {
47
- name: string;
48
- description: string;
47
+ name?: FlatObjectKeys<DefaultLocale>;
48
+ description?: FlatObjectKeys<DefaultLocale>;
49
49
  defaultDescription: string;
50
50
  }>): <T extends new (...args: any[]) => {}>(target: T) => {
51
51
  new (...args: any[]): {
52
52
  __tGroups: Record<string, {
53
- name: string;
54
- description: string;
53
+ name?: undefined;
54
+ description?: undefined;
55
55
  defaultDescription: string;
56
56
  }>;
57
57
  };
@@ -95,13 +95,13 @@ export declare function Middlewares(cbs: readonly (keyof RegisteredMiddlewares)[
95
95
  export declare function Declare(declare: DeclareOptions): <T extends new (...args: any[]) => {}>(target: T) => {
96
96
  new (...args: any[]): {
97
97
  name: string;
98
- dm: boolean;
99
98
  nsfw: boolean | undefined;
100
- guild_id: string[] | undefined;
101
99
  default_member_permissions: string | bigint | undefined;
102
- permissions: bigint | undefined;
100
+ botPermissions: bigint | undefined;
101
+ dm?: boolean | undefined;
103
102
  description: string;
104
103
  type: ApplicationCommandType;
104
+ guild_id?: string[] | undefined;
105
105
  };
106
106
  } & T;
107
107
  export {};
@@ -61,23 +61,27 @@ exports.Middlewares = Middlewares;
61
61
  function Declare(declare) {
62
62
  return (target) => class extends target {
63
63
  name = declare.name;
64
- dm = !!declare.dm;
65
64
  nsfw = declare.nsfw;
66
- guild_id = declare.guildId;
67
65
  default_member_permissions = Array.isArray(declare.defaultPermissions)
68
66
  ? declare.defaultPermissions?.reduce((acc, prev) => acc | common_1.PermissionFlagsBits[prev], BigInt(0)).toString()
69
67
  : declare.defaultPermissions;
70
- permissions = Array.isArray(declare.permissions)
71
- ? declare.permissions?.reduce((acc, prev) => acc | common_1.PermissionFlagsBits[prev], BigInt(0))
72
- : declare.permissions;
68
+ botPermissions = Array.isArray(declare.botPermissions)
69
+ ? declare.botPermissions?.reduce((acc, prev) => acc | common_1.PermissionFlagsBits[prev], BigInt(0))
70
+ : declare.botPermissions;
71
+ dm;
73
72
  description = '';
74
73
  type = common_1.ApplicationCommandType.ChatInput;
74
+ guild_id;
75
75
  constructor(...args) {
76
76
  super(...args);
77
77
  if ('description' in declare)
78
78
  this.description = declare.description;
79
79
  if ('type' in declare)
80
80
  this.type = declare.type;
81
+ if ('dm' in declare)
82
+ this.dm = !!declare.dm;
83
+ if ('guildId' in declare)
84
+ this.guild_id = declare.guildId;
81
85
  // check if all properties are valid
82
86
  }
83
87
  };
@@ -5,9 +5,10 @@ import { Command } from './applications/chat';
5
5
  import { ContextMenuCommand } from './applications/menu';
6
6
  export declare class CommandHandler extends BaseHandler {
7
7
  protected logger: Logger;
8
+ protected client: BaseClient;
8
9
  values: (Command | ContextMenuCommand)[];
9
10
  protected filter: (path: string) => boolean;
10
- constructor(logger: Logger);
11
+ constructor(logger: Logger, client: BaseClient);
11
12
  reload(resolve: string | Command): Promise<void>;
12
13
  reloadAll(stopIfFail?: boolean): Promise<void>;
13
14
  load(commandsDir: string, client: BaseClient): Promise<(Command | ContextMenuCommand)[]>;
@@ -7,11 +7,13 @@ const chat_1 = require("./applications/chat");
7
7
  const menu_1 = require("./applications/menu");
8
8
  class CommandHandler extends common_1.BaseHandler {
9
9
  logger;
10
+ client;
10
11
  values = [];
11
- filter = (path) => path.endsWith('.js') || path.endsWith('.ts');
12
- constructor(logger) {
12
+ filter = (path) => path.endsWith('.js') || (!path.endsWith('.d.ts') && path.endsWith('.ts'));
13
+ constructor(logger, client) {
13
14
  super(logger);
14
15
  this.logger = logger;
16
+ this.client = client;
15
17
  }
16
18
  async reload(resolve) {
17
19
  if (typeof resolve === 'string') {
@@ -88,6 +90,8 @@ class CommandHandler extends common_1.BaseHandler {
88
90
  option.onInternalError =
89
91
  option.onInternalError?.bind(option) ?? commandInstance.onInternalError?.bind(commandInstance);
90
92
  option.onAfterRun = option.onAfterRun?.bind(option) ?? commandInstance.onAfterRun?.bind(commandInstance);
93
+ option.onPermissionsFail =
94
+ option.onPermissionsFail?.bind(option) ?? commandInstance.onPermissionsFail?.bind(commandInstance);
91
95
  }
92
96
  }
93
97
  this.values.push(commandInstance);
@@ -105,32 +109,74 @@ class CommandHandler extends common_1.BaseHandler {
105
109
  command.name_localizations = {};
106
110
  command.description_localizations = {};
107
111
  for (const locale of Object.keys(client.langs.values)) {
108
- const valueName = client.langs.getKey(locale, command.__t.name);
109
- if (valueName) {
110
- command.name_localizations[locale] = valueName;
112
+ const aliases = this.client.langs.aliases.find(x => x[0] === locale)?.[1] ?? [];
113
+ if (Object.values(common_1.Locale).includes(locale)) {
114
+ if (command.__t.name) {
115
+ const valueName = client.langs.getKey(locale, command.__t.name);
116
+ if (valueName)
117
+ command.name_localizations[locale] = valueName;
118
+ }
119
+ if (command.__t.description) {
120
+ const valueKey = client.langs.getKey(locale, command.__t.description);
121
+ if (valueKey)
122
+ command.description_localizations[locale] = valueKey;
123
+ }
111
124
  }
112
- const valueKey = client.langs.getKey(locale, command.__t.description);
113
- if (valueKey) {
114
- command.description_localizations[locale] = valueKey;
125
+ for (const i of aliases) {
126
+ if (command.__t.name) {
127
+ const valueName = client.langs.getKey(locale, command.__t.name);
128
+ if (valueName)
129
+ command.name_localizations[i] = valueName;
130
+ }
131
+ }
132
+ for (const i of aliases) {
133
+ if (command.__t.description) {
134
+ const valueKey = client.langs.getKey(locale, command.__t.description);
135
+ if (valueKey)
136
+ command.description_localizations[i] = valueKey;
137
+ }
115
138
  }
116
139
  }
117
140
  }
118
141
  if (command instanceof chat_1.Command && command.__tGroups) {
119
142
  command.groups = {};
120
143
  for (const locale of Object.keys(client.langs.values)) {
144
+ const aliases = this.client.langs.aliases.find(x => x[0] === locale)?.[1] ?? [];
121
145
  for (const group in command.__tGroups) {
122
146
  command.groups[group] ??= {
123
147
  defaultDescription: command.__tGroups[group].defaultDescription,
124
148
  description: [],
125
149
  name: [],
126
150
  };
127
- const valueName = client.langs.getKey(locale, command.__tGroups[group].name);
128
- if (valueName) {
129
- command.groups[group].name.push([locale, valueName]);
151
+ if (Object.values(common_1.Locale).includes(locale)) {
152
+ if (command.__tGroups[group].name) {
153
+ const valueName = client.langs.getKey(locale, command.__tGroups[group].name);
154
+ if (valueName) {
155
+ command.groups[group].name.push([locale, valueName]);
156
+ }
157
+ }
158
+ if (command.__tGroups[group].description) {
159
+ const valueKey = client.langs.getKey(locale, command.__tGroups[group].description);
160
+ if (valueKey) {
161
+ command.groups[group].description.push([locale, valueKey]);
162
+ }
163
+ }
130
164
  }
131
- const valueKey = client.langs.getKey(locale, command.__tGroups[group].description);
132
- if (valueKey) {
133
- command.groups[group].description.push([locale, valueKey]);
165
+ for (const i of aliases) {
166
+ if (command.__tGroups[group].name) {
167
+ const valueName = client.langs.getKey(locale, command.__tGroups[group].name);
168
+ if (valueName) {
169
+ command.groups[group].name.push([i, valueName]);
170
+ }
171
+ }
172
+ }
173
+ for (const i of aliases) {
174
+ if (command.__tGroups[group].description) {
175
+ const valueKey = client.langs.getKey(locale, command.__tGroups[group].description);
176
+ if (valueKey) {
177
+ command.groups[group].description.push([i, valueKey]);
178
+ }
179
+ }
134
180
  }
135
181
  }
136
182
  }
@@ -1,8 +1,8 @@
1
+ export * from './applications/shared';
1
2
  export * from './applications/chat';
2
3
  export * from './applications/chatcontext';
3
4
  export * from './applications/menu';
4
5
  export * from './applications/menucontext';
5
6
  export * from './applications/options';
6
- export * from './applications/shared';
7
7
  export * from './decorators';
8
8
  export * from './optionresolver';
@@ -14,11 +14,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./applications/shared"), exports);
18
+ //
17
19
  __exportStar(require("./applications/chat"), exports);
18
20
  __exportStar(require("./applications/chatcontext"), exports);
19
21
  __exportStar(require("./applications/menu"), exports);
20
22
  __exportStar(require("./applications/menucontext"), exports);
21
23
  __exportStar(require("./applications/options"), exports);
22
- __exportStar(require("./applications/shared"), exports);
23
24
  __exportStar(require("./decorators"), exports);
24
25
  __exportStar(require("./optionresolver"), exports);
@@ -1,4 +1,5 @@
1
- import type { APIApplicationCommandInteractionDataOption, APIAttachment, APIInteractionDataResolved, MakeRequired } from '../common';
1
+ import { Attachment, GuildMember } from '..';
2
+ import type { APIApplicationCommandInteractionDataOption, APIInteractionDataResolved, MakeRequired } from '../common';
2
3
  import { ApplicationCommandOptionType } from '../common';
3
4
  import type { AllChannels } from '../structures';
4
5
  import { GuildRole, InteractionGuildMember, User } from '../structures';
@@ -15,7 +16,7 @@ export declare class OptionResolver {
15
16
  private group;
16
17
  constructor(client: UsingClient, options: APIApplicationCommandInteractionDataOption[], parent?: Command | undefined, guildId?: string | undefined, resolved?: APIInteractionDataResolved | undefined);
17
18
  get fullCommandName(): string;
18
- getCommand(): SubCommand | Command | undefined;
19
+ getCommand(): Command | SubCommand | undefined;
19
20
  getAutocompleteValue(): string | undefined;
20
21
  getAutocomplete(): CommandAutocompleteOption | undefined;
21
22
  getParent(): string | undefined;
@@ -23,7 +24,7 @@ export declare class OptionResolver {
23
24
  getGroup(): string | null;
24
25
  get(name: string): OptionResolved | undefined;
25
26
  getHoisted(name: string): OptionResolved | undefined;
26
- getValue(name: string): string | number | boolean | APIAttachment | InteractionGuildMember | User | import("../structures").BaseChannel<import("discord-api-types/payloads/v10/channel").ChannelType> | import("../structures").DMChannel | import("../structures").CategoryChannel | GuildRole | undefined;
27
+ getValue(name: string): string | number | boolean | Attachment | GuildRole | GuildMember | User | import("..").BaseChannel<import("discord-api-types/payloads/v10/channel").ChannelType> | import("..").DMChannel | import("..").CategoryChannel | InteractionGuildMember | undefined;
27
28
  private getTypedOption;
28
29
  getChannel(name: string, required?: true): AllChannels;
29
30
  getString(name: string, required?: true): string;
@@ -35,8 +36,8 @@ export interface OptionResolved {
35
36
  value?: string | number | boolean;
36
37
  options?: OptionResolved[];
37
38
  user?: User;
38
- member?: InteractionGuildMember;
39
- attachment?: APIAttachment;
39
+ member?: GuildMember | InteractionGuildMember;
40
+ attachment?: Attachment;
40
41
  channel?: AllChannels;
41
42
  role?: GuildRole;
42
43
  focused?: boolean;
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.OptionResolver = void 0;
7
+ const __1 = require("..");
7
8
  const common_1 = require("../common");
8
9
  const structures_1 = require("../structures");
9
10
  const channels_1 = __importDefault(require("../structures/channels"));
@@ -37,7 +38,7 @@ class OptionResolver {
37
38
  }
38
39
  getCommand() {
39
40
  if (this.subCommand) {
40
- return (this.parent?.options).find(x => (this.group ? x.group === this.group : true) && x.name === this.subCommand);
41
+ return this.parent?.options?.find(x => (this.group ? x.group === this.group : true) && x.name === this.subCommand);
41
42
  }
42
43
  return this.parent;
43
44
  }
@@ -84,7 +85,7 @@ class OptionResolver {
84
85
  case common_1.ApplicationCommandOptionType.User:
85
86
  return option.member ?? option.user;
86
87
  case common_1.ApplicationCommandOptionType.Mentionable:
87
- return option.member ?? option.user ?? option.channel ?? option.role;
88
+ return option.member ?? option.user ?? option.role;
88
89
  default:
89
90
  return;
90
91
  }
@@ -125,19 +126,22 @@ class OptionResolver {
125
126
  }
126
127
  const member = resolved.members?.[value];
127
128
  if (member) {
128
- resolve.member = new structures_1.InteractionGuildMember(this.client, member, user, this.guildId);
129
+ resolve.member =
130
+ member instanceof __1.GuildMember
131
+ ? member
132
+ : new structures_1.InteractionGuildMember(this.client, member, user, this.guildId);
129
133
  }
130
134
  const channel = resolved.channels?.[value];
131
135
  if (channel) {
132
- resolve.channel = (0, channels_1.default)(channel, this.client);
136
+ resolve.channel = 'fetch' in channel ? channel : (0, channels_1.default)(channel, this.client);
133
137
  }
134
138
  const role = resolved.roles?.[value];
135
139
  if (role) {
136
- resolve.role = new structures_1.GuildRole(this.client, role, this.guildId);
140
+ resolve.role = role instanceof structures_1.GuildRole ? role : new structures_1.GuildRole(this.client, role, this.guildId);
137
141
  }
138
142
  const attachment = resolved.attachments?.[value];
139
143
  if (attachment) {
140
- resolve.attachment = attachment;
144
+ resolve.attachment = new __1.Attachment(this.client, attachment);
141
145
  }
142
146
  }
143
147
  return resolve;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import type { GatewayDispatchPayload, GatewaySendPayload } from 'discord-api-types/v10';
3
3
  import { Worker } from 'node:worker_threads';
4
- import { REST } from '../../api';
4
+ import { ApiHandler } from '../../api';
5
5
  import { ShardManager, type ShardManagerOptions } from '../../websocket';
6
6
  import { Logger } from '../it/logger';
7
7
  import type { MakeRequired } from '../types/util';
@@ -11,7 +11,7 @@ import type { MakeRequired } from '../types/util';
11
11
  export declare class Watcher extends ShardManager {
12
12
  worker?: Worker;
13
13
  logger: Logger;
14
- rest?: REST;
14
+ rest?: ApiHandler;
15
15
  options: MakeRequired<WatcherOptions, 'intents' | 'token' | 'handlePayload' | 'info'>;
16
16
  /**
17
17
  * Initializes a new instance of the Watcher class.
@@ -31,7 +31,7 @@ export declare class Watcher extends ShardManager {
31
31
  */
32
32
  protected build(): void;
33
33
  }
34
- export interface WatcherOptions extends Omit<ShardManagerOptions, 'debug' | 'handlePayload' | 'info' | 'token' | 'intents'> {
34
+ export interface WatcherOptions extends Omit<ShardManagerOptions, 'handlePayload' | 'info' | 'token' | 'intents'> {
35
35
  filePath: string;
36
36
  transpileCommand: string;
37
37
  srcPath: string;
@@ -67,7 +67,9 @@ class Watcher extends websocket_1.ShardManager {
67
67
  async spawnShards() {
68
68
  const RC = await base_1.BaseClient.prototype.getRC();
69
69
  this.options.token = RC.token;
70
- this.rest ??= new api_1.REST({
70
+ this.rest ??= new api_1.ApiHandler({
71
+ baseUrl: 'api/v10',
72
+ domain: 'https://discord.com',
71
73
  token: this.options.token,
72
74
  });
73
75
  this.options.intents = RC.intents;
@@ -1,7 +1,6 @@
1
1
  export * from './it/constants';
2
2
  export * from './it/utils';
3
3
  export * from 'discord-api-types/v10';
4
- export * from './bot/watcher';
5
4
  export * from './it/colors';
6
5
  export * from './it/logger';
7
6
  export * from './shorters/channels';
@@ -11,3 +10,4 @@ export * from './types/options';
11
10
  export * from './types/resolvables';
12
11
  export * from './types/util';
13
12
  export * from './types/write';
13
+ export * from './bot/watcher';