seyfert 1.2.3 → 1.3.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 (125) hide show
  1. package/lib/api/Routes/channels.d.ts +15 -1
  2. package/lib/api/api.js +5 -1
  3. package/lib/api/shared.d.ts +3 -1
  4. package/lib/api/utils/utils.d.ts +1 -1
  5. package/lib/api/utils/utils.js +2 -2
  6. package/lib/builders/Poll.d.ts +16 -0
  7. package/lib/builders/Poll.js +48 -0
  8. package/lib/builders/index.d.ts +1 -0
  9. package/lib/builders/index.js +1 -0
  10. package/lib/cache/adapters/index.d.ts +1 -0
  11. package/lib/cache/adapters/index.js +1 -0
  12. package/lib/cache/adapters/limited.d.ts +50 -0
  13. package/lib/cache/adapters/limited.js +188 -0
  14. package/lib/cache/index.d.ts +5 -2
  15. package/lib/cache/index.js +38 -7
  16. package/lib/cache/resources/channels.d.ts +2 -1
  17. package/lib/cache/resources/default/base.d.ts +3 -3
  18. package/lib/cache/resources/default/base.js +8 -3
  19. package/lib/cache/resources/default/guild-based.d.ts +2 -1
  20. package/lib/cache/resources/default/guild-based.js +7 -3
  21. package/lib/cache/resources/default/guild-related.d.ts +2 -1
  22. package/lib/cache/resources/default/guild-related.js +7 -3
  23. package/lib/cache/resources/emojis.d.ts +2 -0
  24. package/lib/cache/resources/emojis.js +4 -0
  25. package/lib/cache/resources/guilds.d.ts +2 -0
  26. package/lib/cache/resources/guilds.js +4 -0
  27. package/lib/cache/resources/members.d.ts +2 -0
  28. package/lib/cache/resources/members.js +5 -1
  29. package/lib/cache/resources/messages.d.ts +15 -0
  30. package/lib/cache/resources/messages.js +53 -0
  31. package/lib/cache/resources/overwrites.d.ts +2 -0
  32. package/lib/cache/resources/overwrites.js +4 -0
  33. package/lib/cache/resources/presence.d.ts +1 -0
  34. package/lib/cache/resources/presence.js +4 -0
  35. package/lib/cache/resources/roles.d.ts +2 -0
  36. package/lib/cache/resources/roles.js +4 -0
  37. package/lib/cache/resources/stage-instances.d.ts +1 -0
  38. package/lib/cache/resources/stage-instances.js +5 -1
  39. package/lib/cache/resources/stickers.d.ts +2 -0
  40. package/lib/cache/resources/stickers.js +4 -0
  41. package/lib/cache/resources/threads.d.ts +2 -0
  42. package/lib/cache/resources/threads.js +4 -0
  43. package/lib/cache/resources/users.d.ts +2 -0
  44. package/lib/cache/resources/users.js +4 -0
  45. package/lib/cache/resources/voice-states.d.ts +2 -1
  46. package/lib/cache/resources/voice-states.js +8 -4
  47. package/lib/client/base.d.ts +25 -13
  48. package/lib/client/base.js +33 -8
  49. package/lib/client/client.d.ts +6 -5
  50. package/lib/client/client.js +13 -1
  51. package/lib/client/oninteractioncreate.js +2 -2
  52. package/lib/client/onmessagecreate.js +2 -2
  53. package/lib/client/workerclient.d.ts +3 -3
  54. package/lib/client/workerclient.js +18 -3
  55. package/lib/collection.d.ts +8 -3
  56. package/lib/collection.js +22 -4
  57. package/lib/commands/applications/chat.d.ts +8 -14
  58. package/lib/commands/applications/chat.js +2 -20
  59. package/lib/commands/applications/chatcontext.d.ts +1 -1
  60. package/lib/commands/applications/menucontext.d.ts +1 -1
  61. package/lib/commands/handler.d.ts +11 -7
  62. package/lib/commands/handler.js +43 -14
  63. package/lib/common/index.d.ts +2 -0
  64. package/lib/common/index.js +2 -0
  65. package/lib/common/it/utils.d.ts +0 -1
  66. package/lib/common/it/utils.js +0 -1
  67. package/lib/common/shorters/channels.d.ts +5 -3
  68. package/lib/common/shorters/channels.js +24 -10
  69. package/lib/common/shorters/guilds.d.ts +7 -6
  70. package/lib/common/shorters/guilds.js +23 -4
  71. package/lib/common/shorters/interaction.d.ts +13 -0
  72. package/lib/common/shorters/interaction.js +61 -0
  73. package/lib/common/shorters/messages.d.ts +6 -3
  74. package/lib/common/shorters/messages.js +33 -15
  75. package/lib/common/shorters/roles.d.ts +3 -3
  76. package/lib/common/shorters/roles.js +12 -17
  77. package/lib/common/shorters/templates.d.ts +7 -6
  78. package/lib/common/shorters/templates.js +28 -6
  79. package/lib/common/shorters/threads.d.ts +39 -0
  80. package/lib/common/shorters/threads.js +76 -0
  81. package/lib/common/shorters/webhook.d.ts +1 -1
  82. package/lib/common/shorters/webhook.js +8 -2
  83. package/lib/common/types/util.d.ts +8 -2
  84. package/lib/common/types/write.d.ts +8 -5
  85. package/lib/components/ButtonComponent.js +1 -1
  86. package/lib/components/componentcontext.d.ts +1 -1
  87. package/lib/components/handler.d.ts +6 -17
  88. package/lib/components/handler.js +7 -2
  89. package/lib/events/handler.d.ts +8 -14
  90. package/lib/events/handler.js +9 -4
  91. package/lib/events/hooks/auto_moderation.d.ts +5 -1
  92. package/lib/events/hooks/guild.d.ts +692 -23
  93. package/lib/events/hooks/guild.js +2 -2
  94. package/lib/events/hooks/integration.d.ts +52 -47
  95. package/lib/events/hooks/interactions.d.ts +1 -1
  96. package/lib/events/hooks/invite.d.ts +67 -3
  97. package/lib/events/hooks/message.d.ts +96 -12
  98. package/lib/events/hooks/message.js +18 -7
  99. package/lib/events/hooks/presence.d.ts +48 -2
  100. package/lib/events/hooks/thread.d.ts +155 -18
  101. package/lib/events/hooks/typing.d.ts +13 -1
  102. package/lib/events/hooks/voice.d.ts +13 -1
  103. package/lib/langs/handler.d.ts +4 -8
  104. package/lib/langs/handler.js +7 -2
  105. package/lib/structures/AutoModerationRule.d.ts +7 -7
  106. package/lib/structures/AutoModerationRule.js +2 -1
  107. package/lib/structures/Guild.d.ts +15 -13
  108. package/lib/structures/GuildRole.d.ts +5 -5
  109. package/lib/structures/GuildTemplate.d.ts +10 -10
  110. package/lib/structures/Interaction.d.ts +4 -4
  111. package/lib/structures/Interaction.js +27 -48
  112. package/lib/structures/Message.d.ts +5 -3
  113. package/lib/structures/Message.js +5 -0
  114. package/lib/structures/Poll.d.ts +15 -0
  115. package/lib/structures/Poll.js +26 -0
  116. package/lib/structures/User.js +2 -2
  117. package/lib/structures/Webhook.d.ts +2 -2
  118. package/lib/structures/channels.d.ts +6 -3
  119. package/lib/structures/channels.js +16 -8
  120. package/lib/structures/extra/Permissions.d.ts +1 -0
  121. package/lib/structures/index.d.ts +1 -0
  122. package/lib/structures/index.js +1 -0
  123. package/lib/websocket/SharedTypes.d.ts +7 -2
  124. package/lib/websocket/discord/shard.js +1 -1
  125. package/package.json +8 -8
@@ -1,17 +1,20 @@
1
- import type { APIActionRowComponent, APIEmbed, APIInteractionResponseCallbackData, APIInteractionResponseChannelMessageWithSource, APIMessageActionRowComponent, APIModalInteractionResponse, RESTPatchAPIChannelMessageJSONBody, RESTPatchAPIWebhookWithTokenMessageJSONBody, RESTPostAPIChannelMessageJSONBody, RESTPostAPIWebhookWithTokenJSONBody } from 'discord-api-types/v10';
1
+ import type { APIActionRowComponent, APIEmbed, APIInteractionResponseCallbackData, APIInteractionResponseChannelMessageWithSource, APIMessageActionRowComponent, APIModalInteractionResponse, RESTAPIPollCreate, RESTPatchAPIChannelMessageJSONBody, RESTPatchAPIWebhookWithTokenMessageJSONBody, RESTPostAPIChannelMessageJSONBody, RESTPostAPIWebhookWithTokenJSONBody } from 'discord-api-types/v10';
2
2
  import type { RawFile } from '../../api';
3
- import type { ActionRow, Attachment, AttachmentBuilder, BuilderComponents, Embed, Modal } from '../../builders';
3
+ import type { ActionRow, Attachment, AttachmentBuilder, BuilderComponents, Embed, Modal, PollBuilder } from '../../builders';
4
4
  import type { OmitInsert } from './util';
5
5
  export interface ResolverProps {
6
6
  embeds?: Embed[] | APIEmbed[] | undefined;
7
7
  components?: APIActionRowComponent<APIMessageActionRowComponent>[] | ActionRow<BuilderComponents>[] | undefined;
8
8
  files?: AttachmentBuilder[] | Attachment[] | RawFile[] | undefined;
9
9
  }
10
- export type MessageCreateBodyRequest = OmitInsert<RESTPostAPIChannelMessageJSONBody, 'components' | 'embeds', ResolverProps>;
10
+ export interface SendResolverProps extends ResolverProps {
11
+ poll?: PollBuilder | RESTAPIPollCreate | undefined;
12
+ }
13
+ export type MessageCreateBodyRequest = OmitInsert<RESTPostAPIChannelMessageJSONBody, 'components' | 'embeds' | 'poll', SendResolverProps>;
11
14
  export type MessageUpdateBodyRequest = OmitInsert<RESTPatchAPIChannelMessageJSONBody, 'components' | 'embeds', ResolverProps>;
12
- export type MessageWebhookCreateBodyRequest = OmitInsert<RESTPostAPIWebhookWithTokenJSONBody, 'components' | 'embeds', ResolverProps>;
15
+ export type MessageWebhookCreateBodyRequest = OmitInsert<RESTPostAPIWebhookWithTokenJSONBody, 'components' | 'embeds' | 'poll', SendResolverProps>;
13
16
  export type MessageWebhookUpdateBodyRequest = OmitInsert<RESTPatchAPIWebhookWithTokenMessageJSONBody, 'components' | 'embeds', ResolverProps>;
14
17
  export type InteractionMessageUpdateBodyRequest = OmitInsert<RESTPatchAPIWebhookWithTokenMessageJSONBody, 'components' | 'embeds', ResolverProps>;
15
18
  export type ComponentInteractionMessageUpdate = OmitInsert<APIInteractionResponseCallbackData, 'components' | 'embeds', ResolverProps>;
16
- export type InteractionCreateBodyRequest = OmitInsert<APIInteractionResponseChannelMessageWithSource['data'], 'components' | 'embeds', ResolverProps>;
19
+ export type InteractionCreateBodyRequest = OmitInsert<APIInteractionResponseChannelMessageWithSource['data'], 'components' | 'embeds' | 'poll', SendResolverProps>;
17
20
  export type ModalCreateBodyRequest = APIModalInteractionResponse['data'] | Modal;
@@ -8,7 +8,7 @@ class LinkButtonComponent extends BaseComponent_1.BaseComponent {
8
8
  return this.data.style;
9
9
  }
10
10
  get url() {
11
- // @ts-ignore
11
+ // @ts-expect-error
12
12
  return this.data.url;
13
13
  }
14
14
  get label() {
@@ -46,7 +46,7 @@ export declare class ComponentContext<Type extends keyof ComponentCommandInterac
46
46
  * Edits the response of the interaction.
47
47
  * @param body - The updated body of the response.
48
48
  */
49
- editResponse(body: InteractionMessageUpdateBodyRequest): Promise<Message>;
49
+ editResponse(body: InteractionMessageUpdateBodyRequest): Promise<WebhookMessage>;
50
50
  /**
51
51
  * Updates the interaction with new data.
52
52
  * @param body - The updated body of the interaction.
@@ -16,23 +16,6 @@ type COMPONENTS = {
16
16
  timeout?: NodeJS.Timeout;
17
17
  __run: (customId: string | string[] | RegExp, callback: ComponentCallback) => any;
18
18
  };
19
- export interface ComponentHandlerLike {
20
- readonly values: Map<string, COMPONENTS>;
21
- readonly commands: (ComponentCommand | ModalCommand)[];
22
- readonly modals: Map<string, ModalSubmitCallback> | LimitedCollection<string, ModalSubmitCallback>;
23
- onFail: ComponentHandler['onFail'];
24
- createComponentCollector: ComponentHandler['createComponentCollector'];
25
- hasModal: ComponentHandler['hasModal'];
26
- onModalSubmit: ComponentHandler['onModalSubmit'];
27
- executeModal: ComponentHandler['executeModal'];
28
- hasComponent: ComponentHandler['hasComponent'];
29
- executeComponent: ComponentHandler['executeComponent'];
30
- onComponent: ComponentHandler['onComponent'];
31
- load: ComponentHandler['load'];
32
- reload: ComponentHandler['reload'];
33
- reloadAll: ComponentHandler['reloadAll'];
34
- onMessageDelete: ComponentHandler['onMessageDelete'];
35
- }
36
19
  export declare class ComponentHandler extends BaseHandler {
37
20
  protected client: UsingClient;
38
21
  onFail: OnFailCallback;
@@ -57,5 +40,11 @@ export declare class ComponentHandler extends BaseHandler {
57
40
  reloadAll(): Promise<void>;
58
41
  executeComponent(interaction: ComponentInteraction): Promise<void>;
59
42
  executeModal(interaction: ModalSubmitInteraction): Promise<void>;
43
+ setHandlers({ callback }: {
44
+ callback: ComponentHandler['callback'];
45
+ }): void;
46
+ callback: (file: {
47
+ new (): ModalCommand | ComponentCommand;
48
+ }) => ModalCommand | ComponentCommand | false;
60
49
  }
61
50
  export {};
@@ -121,7 +121,9 @@ class ComponentHandler extends common_1.BaseHandler {
121
121
  for (let i = 0; i < paths.length; i++) {
122
122
  let component;
123
123
  try {
124
- component = new paths[i].file();
124
+ component = this.callback(paths[i].file);
125
+ if (!component)
126
+ continue;
125
127
  }
126
128
  catch (e) {
127
129
  if (e instanceof Error && e.message === 'paths[i].file is not a constructor') {
@@ -138,7 +140,6 @@ class ComponentHandler extends common_1.BaseHandler {
138
140
  continue;
139
141
  component.__filePath = paths[i].path;
140
142
  this.commands.push(component);
141
- await this.__callback?.(component);
142
143
  }
143
144
  }
144
145
  async reload(path) {
@@ -201,5 +202,9 @@ class ComponentHandler extends common_1.BaseHandler {
201
202
  }
202
203
  }
203
204
  }
205
+ setHandlers({ callback }) {
206
+ this.callback = callback;
207
+ }
208
+ callback = (file) => new file();
204
209
  }
205
210
  exports.ComponentHandler = ComponentHandler;
@@ -1,23 +1,14 @@
1
1
  import type { GatewayDispatchPayload } from 'discord-api-types/v10';
2
2
  import type { Client, WorkerClient } from '../client';
3
- import { BaseHandler, type MakeRequired, type OnFailCallback, type SnakeCase } from '../common';
3
+ import { BaseHandler, type MakeRequired, type SnakeCase } from '../common';
4
4
  import type { ClientEvents } from '../events/hooks';
5
5
  import type { ClientEvent, ClientNameEvents } from './event';
6
- type EventValue = MakeRequired<ClientEvent, '__filePath'> & {
6
+ export type EventValue = MakeRequired<ClientEvent, '__filePath'> & {
7
7
  fired?: boolean;
8
8
  };
9
- type GatewayEvents = Uppercase<SnakeCase<keyof ClientEvents>>;
10
- export interface EventHandlerLike {
11
- runEvent: EventHandler['runEvent'];
12
- execute: EventHandler['execute'];
13
- load: EventHandler['load'];
14
- reload: EventHandler['reload'];
15
- reloadAll: EventHandler['reloadAll'];
16
- values: EventHandler['values'];
17
- onFail: EventHandler['onFail'];
18
- }
9
+ export type GatewayEvents = Uppercase<SnakeCase<keyof ClientEvents>>;
19
10
  export declare class EventHandler extends BaseHandler {
20
- onFail: OnFailCallback;
11
+ onFail: (event: GatewayEvents, err: unknown) => void;
21
12
  protected filter: (path: string) => boolean;
22
13
  values: Partial<Record<GatewayEvents, EventValue>>;
23
14
  load(eventsDir: string): Promise<void>;
@@ -25,5 +16,8 @@ export declare class EventHandler extends BaseHandler {
25
16
  runEvent(name: GatewayEvents, client: Client | WorkerClient, packet: any, shardId: number): Promise<void>;
26
17
  reload(name: ClientNameEvents): Promise<any>;
27
18
  reloadAll(): Promise<void>;
19
+ setHandlers({ callback }: {
20
+ callback: EventHandler['callback'];
21
+ }): void;
22
+ callback: (file: ClientEvent) => ClientEvent | false;
28
23
  }
29
- export {};
@@ -27,19 +27,20 @@ exports.EventHandler = void 0;
27
27
  const common_1 = require("../common");
28
28
  const RawEvents = __importStar(require("../events/hooks"));
29
29
  class EventHandler extends common_1.BaseHandler {
30
- onFail = err => this.logger.warn('<Client>.events.onFail', err);
30
+ onFail = (event, err) => this.logger.warn('<Client>.events.onFail', err, event);
31
31
  filter = (path) => path.endsWith('.js') || (!path.endsWith('.d.ts') && path.endsWith('.ts'));
32
32
  values = {};
33
33
  async load(eventsDir) {
34
34
  for (const i of await this.loadFilesK(await this.getFiles(eventsDir))) {
35
- const instance = i.file;
35
+ const instance = this.callback(i.file);
36
+ if (!instance)
37
+ continue;
36
38
  if (typeof instance?.run !== 'function') {
37
39
  this.logger.warn(i.path.split(process.cwd()).slice(1).join(process.cwd()), 'Missing run function, use `export default {...}` syntax');
38
40
  continue;
39
41
  }
40
42
  instance.__filePath = i.path;
41
43
  this.values[common_1.ReplaceRegex.snake(instance.data.name).toUpperCase()] = instance;
42
- await this.__callback?.(instance);
43
44
  }
44
45
  }
45
46
  async execute(name, ...args) {
@@ -95,7 +96,7 @@ class EventHandler extends common_1.BaseHandler {
95
96
  await Event.run(...[hook, client, shardId]);
96
97
  }
97
98
  catch (e) {
98
- await this.onFail(e);
99
+ await this.onFail(name, e);
99
100
  }
100
101
  }
101
102
  async reload(name) {
@@ -114,5 +115,9 @@ class EventHandler extends common_1.BaseHandler {
114
115
  await this.reload(common_1.ReplaceRegex.camel(i));
115
116
  }
116
117
  }
118
+ setHandlers({ callback }) {
119
+ this.callback = callback;
120
+ }
121
+ callback = (file) => file;
117
122
  }
118
123
  exports.EventHandler = EventHandler;
@@ -5,7 +5,11 @@ export declare const AUTO_MODERATION_ACTION_EXECUTION: (_self: BaseClient, data:
5
5
  guildId: string;
6
6
  action: {
7
7
  type: import("discord-api-types/v10").AutoModerationActionType;
8
- metadata?: import("discord-api-types/v10").APIAutoModerationActionMetadata | undefined;
8
+ metadata?: {
9
+ channelId?: string | undefined;
10
+ durationSeconds?: number | undefined;
11
+ customMessage?: string | undefined;
12
+ } | undefined;
9
13
  };
10
14
  ruleId: string;
11
15
  ruleTriggerType: import("discord-api-types/v10").AutoModerationRuleTriggerType;