seyfert 1.0.1 → 1.1.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 (103) hide show
  1. package/lib/api/CDN.d.ts +1 -1
  2. package/lib/api/CDN.js +0 -2
  3. package/lib/api/Router.js +2 -2
  4. package/lib/api/Routes/applications.d.ts +29 -33
  5. package/lib/api/Routes/channels.d.ts +11 -17
  6. package/lib/api/Routes/interactions.d.ts +3 -7
  7. package/lib/api/Routes/webhooks.d.ts +4 -6
  8. package/lib/builders/Attachment.d.ts +2 -3
  9. package/lib/cache/adapters/redis.js +6 -0
  10. package/lib/cache/adapters/workeradapter.d.ts +4 -4
  11. package/lib/cache/adapters/workeradapter.js +10 -5
  12. package/lib/cache/index.d.ts +4 -5
  13. package/lib/cache/index.js +4 -3
  14. package/lib/cache/resources/default/base.d.ts +2 -1
  15. package/lib/cache/resources/default/guild-based.d.ts +2 -1
  16. package/lib/cache/resources/default/guild-based.js +6 -6
  17. package/lib/cache/resources/default/guild-related.d.ts +2 -1
  18. package/lib/cache/resources/default/guild-related.js +1 -1
  19. package/lib/cache/resources/guilds.js +2 -1
  20. package/lib/cache/resources/overwrites.d.ts +1 -1
  21. package/lib/cache/resources/overwrites.js +7 -1
  22. package/lib/client/base.d.ts +18 -170
  23. package/lib/client/base.js +11 -14
  24. package/lib/client/client.d.ts +5 -0
  25. package/lib/client/client.js +4 -1
  26. package/lib/client/oninteractioncreate.js +2 -2
  27. package/lib/client/onmessagecreate.js +188 -152
  28. package/lib/client/workerclient.d.ts +1 -0
  29. package/lib/client/workerclient.js +36 -15
  30. package/lib/collection.js +2 -2
  31. package/lib/commands/applications/chat.d.ts +15 -7
  32. package/lib/commands/applications/chat.js +7 -7
  33. package/lib/commands/applications/chatcontext.d.ts +5 -3
  34. package/lib/commands/applications/chatcontext.js +6 -1
  35. package/lib/commands/applications/menu.d.ts +5 -1
  36. package/lib/commands/applications/menu.js +4 -0
  37. package/lib/commands/applications/menucontext.d.ts +4 -2
  38. package/lib/commands/applications/menucontext.js +6 -1
  39. package/lib/commands/applications/options.d.ts +1 -2
  40. package/lib/commands/decorators.d.ts +17 -5
  41. package/lib/commands/decorators.js +17 -7
  42. package/lib/commands/handler.d.ts +5 -5
  43. package/lib/commands/handler.js +40 -36
  44. package/lib/commands/optionresolver.d.ts +11 -4
  45. package/lib/commands/optionresolver.js +6 -4
  46. package/lib/common/index.d.ts +7 -0
  47. package/lib/common/index.js +7 -0
  48. package/lib/common/it/utils.js +2 -0
  49. package/lib/common/shorters/channels.d.ts +67 -129
  50. package/lib/common/shorters/channels.js +119 -135
  51. package/lib/common/shorters/emojis.d.ts +47 -0
  52. package/lib/common/shorters/emojis.js +80 -0
  53. package/lib/common/shorters/guilds.d.ts +22 -249
  54. package/lib/common/shorters/guilds.js +51 -140
  55. package/lib/common/shorters/members.d.ts +82 -108
  56. package/lib/common/shorters/members.js +151 -166
  57. package/lib/common/shorters/messages.d.ts +11 -23
  58. package/lib/common/shorters/messages.js +58 -104
  59. package/lib/common/shorters/reactions.d.ts +10 -0
  60. package/lib/common/shorters/reactions.js +45 -0
  61. package/lib/common/shorters/roles.d.ts +39 -7
  62. package/lib/common/shorters/roles.js +74 -42
  63. package/lib/common/shorters/templates.d.ts +6 -8
  64. package/lib/common/shorters/templates.js +17 -21
  65. package/lib/common/shorters/users.d.ts +4 -0
  66. package/lib/common/shorters/users.js +30 -0
  67. package/lib/common/shorters/webhook.d.ts +62 -26
  68. package/lib/common/shorters/webhook.js +113 -58
  69. package/lib/common/types/options.d.ts +2 -2
  70. package/lib/components/handler.d.ts +10 -7
  71. package/lib/components/handler.js +20 -5
  72. package/lib/index.d.ts +4 -2
  73. package/lib/langs/handler.js +7 -2
  74. package/lib/structures/AutoModerationRule.d.ts +2 -2
  75. package/lib/structures/ClientUser.d.ts +2 -2
  76. package/lib/structures/Guild.d.ts +2 -2
  77. package/lib/structures/GuildEmoji.d.ts +4 -4
  78. package/lib/structures/GuildEmoji.js +7 -7
  79. package/lib/structures/GuildMember.d.ts +6 -6
  80. package/lib/structures/GuildMember.js +2 -2
  81. package/lib/structures/GuildPreview.d.ts +2 -2
  82. package/lib/structures/GuildRole.d.ts +2 -2
  83. package/lib/structures/GuildTemplate.d.ts +2 -2
  84. package/lib/structures/Interaction.d.ts +7 -8
  85. package/lib/structures/Interaction.js +1 -1
  86. package/lib/structures/Message.d.ts +7 -6
  87. package/lib/structures/Message.js +7 -4
  88. package/lib/structures/Sticker.d.ts +2 -2
  89. package/lib/structures/Webhook.d.ts +2 -2
  90. package/lib/structures/Webhook.js +3 -3
  91. package/lib/structures/channels.d.ts +19 -20
  92. package/lib/structures/channels.js +13 -25
  93. package/lib/structures/extra/Base.d.ts +1 -2
  94. package/lib/structures/extra/DiscordBase.d.ts +2 -2
  95. package/lib/websocket/constants/index.js +1 -0
  96. package/lib/websocket/discord/shard.js +4 -2
  97. package/lib/websocket/discord/sharder.d.ts +3 -0
  98. package/lib/websocket/discord/sharder.js +12 -5
  99. package/lib/websocket/discord/shared.d.ts +1 -0
  100. package/lib/websocket/discord/worker.d.ts +2 -1
  101. package/lib/websocket/discord/workermanager.d.ts +8 -3
  102. package/lib/websocket/discord/workermanager.js +78 -30
  103. package/package.json +8 -6
@@ -1,5 +1,5 @@
1
1
  import type { ListenerOptions } from '../builders';
2
- import type { BaseClient } from '../client/base';
2
+ import type { UsingClient } from '../commands';
3
3
  import type { APIChannelMention, APIMessage, GatewayMessageCreateDispatchData, ObjectToLower } from '../common';
4
4
  import type { EmojiResolvable } from '../common/types/resolvables';
5
5
  import type { MessageCreateBodyRequest, MessageUpdateBodyRequest } from '../common/types/write';
@@ -23,21 +23,22 @@ export declare class BaseMessage extends DiscordBase {
23
23
  channels: APIChannelMention[];
24
24
  users: (GuildMember | User)[];
25
25
  };
26
- constructor(client: BaseClient, data: MessageData);
26
+ constructor(client: UsingClient, data: MessageData);
27
+ get user(): User;
27
28
  createComponentCollector(options?: ListenerOptions): {
28
- run: (customId: string, callback: import("../builders").ComponentCallback) => any;
29
+ run: (customId: string | RegExp | string[], callback: import("../builders").ComponentCallback) => any;
29
30
  stop: (reason?: string | undefined) => void;
30
31
  };
31
32
  get url(): string;
32
33
  guild(force?: boolean): Promise<import("./Guild").Guild<"cached"> | import("./Guild").Guild<"api">> | undefined;
33
34
  channel(force?: boolean): Promise<import("./channels").AllChannels>;
34
- react(emoji: EmojiResolvable): Promise<never>;
35
+ react(emoji: EmojiResolvable): Promise<void>;
35
36
  private patch;
36
37
  }
37
38
  export interface Message extends BaseMessage, ObjectToLower<Omit<MessageData, 'timestamp' | 'author' | 'mentions' | 'components'>> {
38
39
  }
39
40
  export declare class Message extends BaseMessage {
40
- constructor(client: BaseClient, data: MessageData);
41
+ constructor(client: UsingClient, data: MessageData);
41
42
  fetch(): Promise<Message>;
42
43
  reply(body: Omit<MessageCreateBodyRequest, 'message_reference'>, fail?: boolean): Promise<Message>;
43
44
  edit(body: MessageUpdateBodyRequest): Promise<Message>;
@@ -50,7 +51,7 @@ export type WriteMessageWebhook = MessageWebhookMethodWriteParams;
50
51
  export declare class WebhookMessage extends BaseMessage {
51
52
  readonly webhookId: string;
52
53
  readonly webhookToken: string;
53
- constructor(client: BaseClient, data: MessageData, webhookId: string, webhookToken: string);
54
+ constructor(client: UsingClient, data: MessageData, webhookId: string, webhookToken: string);
54
55
  fetch(): Promise<import("discord-api-types/rest/v10/webhook").RESTGetAPIWebhookWithTokenResult>;
55
56
  edit(body: EditMessageWebhook): Promise<WebhookMessage>;
56
57
  write(body: WriteMessageWebhook): Promise<WebhookMessage | null>;
@@ -23,6 +23,9 @@ class BaseMessage extends DiscordBase_1.DiscordBase {
23
23
  this.components = data.components?.map(x => new ActionRow_1.MessageActionRowComponent(x)) ?? [];
24
24
  this.patch(data);
25
25
  }
26
+ get user() {
27
+ return this.author;
28
+ }
26
29
  createComponentCollector(options) {
27
30
  return this.client.components.createComponentCollector(this.id, options);
28
31
  }
@@ -38,7 +41,7 @@ class BaseMessage extends DiscordBase_1.DiscordBase {
38
41
  return this.client.channels.fetch(this.channelId, force);
39
42
  }
40
43
  react(emoji) {
41
- return this.client.messages.reactions.add(this.id, this.channelId, emoji);
44
+ return this.client.reactions.add(this.id, this.channelId, emoji);
42
45
  }
43
46
  patch(data) {
44
47
  if ('guild_id' in data) {
@@ -114,13 +117,13 @@ class WebhookMessage extends BaseMessage {
114
117
  return this.api.webhooks(this.webhookId)(this.webhookToken).get({ query: this.thread?.id });
115
118
  }
116
119
  edit(body) {
117
- return this.client.webhooks.messages.edit(this.webhookId, this.webhookToken, { ...body, messageId: this.id });
120
+ return this.client.webhooks.editMessage(this.webhookId, this.webhookToken, { ...body, messageId: this.id });
118
121
  }
119
122
  write(body) {
120
- return this.client.webhooks.messages.write(this.webhookId, this.webhookToken, body);
123
+ return this.client.webhooks.writeMessage(this.webhookId, this.webhookToken, body);
121
124
  }
122
125
  delete(reason) {
123
- return this.client.webhooks.messages.delete(this.webhookId, this.webhookToken, this.id, reason);
126
+ return this.client.webhooks.deleteMessage(this.webhookId, this.webhookToken, this.id, reason);
124
127
  }
125
128
  }
126
129
  exports.WebhookMessage = WebhookMessage;
@@ -1,5 +1,5 @@
1
+ import type { UsingClient } from '..';
1
2
  import type { Attachment } from '../builders';
2
- import type { BaseClient } from '../client/base';
3
3
  import type { APISticker, MethodContext, ObjectToLower, RESTPatchAPIGuildStickerJSONBody, RESTPostAPIGuildStickerFormDataBody } from '../common';
4
4
  import { User } from './User';
5
5
  import { DiscordBase } from './extra/DiscordBase';
@@ -7,7 +7,7 @@ export interface Sticker extends DiscordBase, ObjectToLower<Omit<APISticker, 'us
7
7
  }
8
8
  export declare class Sticker extends DiscordBase {
9
9
  user?: User;
10
- constructor(client: BaseClient, data: APISticker);
10
+ constructor(client: UsingClient, data: APISticker);
11
11
  guild(force?: boolean): Promise<import("./Guild").Guild<"cached"> | import("./Guild").Guild<"api">> | undefined;
12
12
  edit(body: RESTPatchAPIGuildStickerJSONBody, reason?: string): Promise<Sticker> | undefined;
13
13
  fetch(force?: boolean): Promise<Sticker> | undefined;
@@ -1,4 +1,4 @@
1
- import type { BaseClient } from '../client/base';
1
+ import type { UsingClient } from '../commands';
2
2
  import type { APIWebhook, ImageOptions, MessageWebhookCreateBodyRequest, MessageWebhookPayload, MessageWebhookUpdateBodyRequest, MethodContext, ObjectToLower, RESTGetAPIWebhookWithTokenMessageQuery, RESTPatchAPIWebhookJSONBody, RESTPatchAPIWebhookWithTokenJSONBody, RESTPostAPIWebhookWithTokenQuery } from '../common';
3
3
  import { AnonymousGuild } from './AnonymousGuild';
4
4
  import { User } from './User';
@@ -9,7 +9,7 @@ export declare class Webhook extends DiscordBase {
9
9
  user?: User;
10
10
  sourceGuild?: Partial<AnonymousGuild>;
11
11
  messages: ReturnType<typeof Webhook.messages>;
12
- constructor(client: BaseClient, data: APIWebhook);
12
+ constructor(client: UsingClient, data: APIWebhook);
13
13
  guild(force?: boolean): Promise<import("./Guild").Guild<"cached"> | import("./Guild").Guild<"api">> | undefined;
14
14
  channel(force?: boolean): Promise<import("./channels").BaseChannel<import("discord-api-types/payloads/v10/channel").ChannelType> | import("./channels").DMChannel | import("./channels").CategoryChannel | undefined>;
15
15
  avatarURL(options?: ImageOptions): string | null;
@@ -47,9 +47,9 @@ class Webhook extends DiscordBase_1.DiscordBase {
47
47
  }
48
48
  static messages({ client, webhookId, webhookToken }) {
49
49
  return {
50
- write: (payload) => client.webhooks.messages.write(webhookId, webhookToken, payload),
51
- edit: (payload) => client.webhooks.messages.edit(webhookId, webhookToken, payload),
52
- delete: (messageId, reason) => client.webhooks.messages.delete(webhookId, webhookToken, messageId, reason),
50
+ write: (payload) => client.webhooks.writeMessage(webhookId, webhookToken, payload),
51
+ edit: (payload) => client.webhooks.editMessage(webhookId, webhookToken, payload),
52
+ delete: (messageId, reason) => client.webhooks.deleteMessage(webhookId, webhookToken, messageId, reason),
53
53
  };
54
54
  }
55
55
  static methods({ client, webhookId, webhookToken }) {
@@ -1,13 +1,12 @@
1
1
  import { ChannelType, VideoQualityMode, type APIDMChannel, type APIGuildCategoryChannel, type APIGuildForumChannel, type APIGuildMediaChannel, type APIGuildStageVoiceChannel, type APIGuildVoiceChannel, type APINewsChannel, type APITextChannel, type APIThreadChannel, type ThreadAutoArchiveDuration } from 'discord-api-types/v10';
2
- import type { BaseClient } from '../client/base';
2
+ import type { UsingClient } from '../commands';
3
3
  import type { APIChannelBase, APIGuildChannel, APIGuildForumDefaultReactionEmoji, APIGuildForumTag, EmojiResolvable, MessageCreateBodyRequest, MessageUpdateBodyRequest, MethodContext, ObjectToLower, RESTGetAPIChannelMessageReactionUsersQuery, RESTPatchAPIChannelJSONBody, RESTPatchAPIGuildChannelPositionsJSONBody, RESTPostAPIChannelWebhookJSONBody, RESTPostAPIGuildChannelJSONBody, SortOrderType, StringToNumber, ToClass } from '../common';
4
4
  import type { GuildMember } from './GuildMember';
5
5
  import type { GuildRole } from './GuildRole';
6
- import { Webhook } from './Webhook';
7
6
  import { DiscordBase } from './extra/DiscordBase';
8
7
  export declare class BaseChannel<T extends ChannelType> extends DiscordBase<APIChannelBase<ChannelType>> {
9
8
  type: T;
10
- constructor(client: BaseClient, data: APIChannelBase<ChannelType>);
9
+ constructor(client: UsingClient, data: APIChannelBase<ChannelType>);
11
10
  static __intent__(id: '@me'): 'DirectMessages';
12
11
  static __intent__(id: string): 'DirectMessages' | 'Guilds';
13
12
  /** The URL to the channel */
@@ -58,7 +57,7 @@ interface IChannelTypes {
58
57
  export interface BaseGuildChannel extends ObjectToLower<Omit<APIGuildChannel<ChannelType>, 'permission_overwrites'>> {
59
58
  }
60
59
  export declare class BaseGuildChannel extends BaseChannel<ChannelType> {
61
- constructor(client: BaseClient, data: APIGuildChannel<ChannelType>);
60
+ constructor(client: UsingClient, data: APIGuildChannel<ChannelType>);
62
61
  permissionOverwrites: {
63
62
  fetch: () => import("..").ReturnCache<{
64
63
  type: number;
@@ -104,7 +103,7 @@ export declare class BaseGuildChannel extends BaseChannel<ChannelType> {
104
103
  export interface MessagesMethods extends BaseChannel<ChannelType> {
105
104
  }
106
105
  export declare class MessagesMethods extends DiscordBase {
107
- typing(): Promise<never>;
106
+ typing(): Promise<void>;
108
107
  messages: {
109
108
  write: (body: MessageCreateBodyRequest) => Promise<import("./Message").Message>;
110
109
  edit: (messageId: string, body: MessageUpdateBodyRequest) => Promise<import("./Message").Message>;
@@ -119,10 +118,10 @@ export declare class MessagesMethods extends DiscordBase {
119
118
  delete: (messageId: string, reason?: string) => Promise<never>;
120
119
  };
121
120
  reactions: {
122
- add: (messageId: string, emoji: EmojiResolvable) => Promise<never>;
123
- delete: (messageId: string, emoji: EmojiResolvable, userId?: string) => Promise<never>;
121
+ add: (messageId: string, emoji: EmojiResolvable) => Promise<void>;
122
+ delete: (messageId: string, emoji: EmojiResolvable, userId?: string) => Promise<void>;
124
123
  fetch: (messageId: string, emoji: EmojiResolvable, query?: RESTGetAPIChannelMessageReactionUsersQuery) => Promise<import("./User").User[]>;
125
- purge: (messageId: string, emoji?: EmojiResolvable) => Promise<never>;
124
+ purge: (messageId: string, emoji?: EmojiResolvable) => Promise<void>;
126
125
  };
127
126
  static messages(ctx: MethodContext<{
128
127
  channelId: string;
@@ -137,10 +136,10 @@ export declare class MessagesMethods extends DiscordBase {
137
136
  static reactions(ctx: MethodContext<{
138
137
  channelId: string;
139
138
  }>): {
140
- add: (messageId: string, emoji: EmojiResolvable) => Promise<never>;
141
- delete: (messageId: string, emoji: EmojiResolvable, userId?: string) => Promise<never>;
139
+ add: (messageId: string, emoji: EmojiResolvable) => Promise<void>;
140
+ delete: (messageId: string, emoji: EmojiResolvable, userId?: string) => Promise<void>;
142
141
  fetch: (messageId: string, emoji: EmojiResolvable, query?: RESTGetAPIChannelMessageReactionUsersQuery) => Promise<import("./User").User[]>;
143
- purge: (messageId: string, emoji?: EmojiResolvable) => Promise<never>;
142
+ purge: (messageId: string, emoji?: EmojiResolvable) => Promise<void>;
144
143
  };
145
144
  static pins(ctx: MethodContext<{
146
145
  channelId: string;
@@ -155,7 +154,7 @@ export interface TextBaseGuildChannel extends ObjectToLower<Omit<APITextChannel,
155
154
  }
156
155
  export declare class TextBaseGuildChannel extends BaseGuildChannel {
157
156
  }
158
- export default function channelFrom(data: APIChannelBase<ChannelType>, client: BaseClient): AllChannels;
157
+ export default function channelFrom(data: APIChannelBase<ChannelType>, client: UsingClient): AllChannels;
159
158
  export interface TopicableGuildChannel extends BaseChannel<ChannelType> {
160
159
  }
161
160
  export declare class TopicableGuildChannel extends DiscordBase {
@@ -180,24 +179,24 @@ export declare class VoiceChannelMethods extends DiscordBase {
180
179
  }
181
180
  export declare class WebhookGuildMethods extends DiscordBase {
182
181
  webhooks: {
183
- list: () => Promise<Webhook[]>;
182
+ list: () => Promise<import("./Webhook").Webhook[]>;
184
183
  };
185
184
  static guild(ctx: MethodContext<{
186
185
  guildId: string;
187
186
  }>): {
188
- list: () => Promise<Webhook[]>;
187
+ list: () => Promise<import("./Webhook").Webhook[]>;
189
188
  };
190
189
  }
191
190
  export declare class WebhookChannelMethods extends DiscordBase {
192
191
  webhooks: {
193
- list: () => Promise<Webhook[]>;
194
- create: (body: RESTPostAPIChannelWebhookJSONBody) => Promise<Webhook>;
192
+ list: () => Promise<import("./Webhook").Webhook[]>;
193
+ create: (body: RESTPostAPIChannelWebhookJSONBody) => Promise<import("./Webhook").Webhook>;
195
194
  };
196
195
  static channel(ctx: MethodContext<{
197
196
  channelId: string;
198
197
  }>): {
199
- list: () => Promise<Webhook[]>;
200
- create: (body: RESTPostAPIChannelWebhookJSONBody) => Promise<Webhook>;
198
+ list: () => Promise<import("./Webhook").Webhook[]>;
199
+ create: (body: RESTPostAPIChannelWebhookJSONBody) => Promise<import("./Webhook").Webhook>;
201
200
  };
202
201
  }
203
202
  export interface TextGuildChannel extends ObjectToLower<Omit<APITextChannel, 'type' | 'permission_overwrites'>>, BaseGuildChannel, TextBaseGuildChannel, WebhookChannelMethods {
@@ -238,8 +237,8 @@ export interface ThreadChannel extends ObjectToLower<Omit<APIThreadChannel, 'per
238
237
  export declare class ThreadChannel extends BaseChannel<ChannelType.PublicThread | ChannelType.AnnouncementThread | ChannelType.PrivateThread> {
239
238
  type: ChannelType.PublicThread | ChannelType.AnnouncementThread | ChannelType.PrivateThread;
240
239
  webhooks: {
241
- list: () => Promise<Webhook[]>;
242
- create: (body: RESTPostAPIChannelWebhookJSONBody) => Promise<Webhook>;
240
+ list: () => Promise<import("./Webhook").Webhook[]>;
241
+ create: (body: RESTPostAPIChannelWebhookJSONBody) => Promise<import("./Webhook").Webhook>;
243
242
  };
244
243
  setRatelimitPerUser(rate_limit_per_user: number | null | undefined): Promise<AllChannels>;
245
244
  pin(reason?: string): Promise<AllChannels>;
@@ -10,7 +10,6 @@ exports.DirectoryChannel = exports.NewsChannel = exports.CategoryChannel = expor
10
10
  const v10_1 = require("discord-api-types/v10");
11
11
  const ts_mixer_1 = require("ts-mixer");
12
12
  const builders_1 = require("../builders");
13
- const Webhook_1 = require("./Webhook");
14
13
  const DiscordBase_1 = require("./extra/DiscordBase");
15
14
  const functions_1 = require("./extra/functions");
16
15
  class BaseChannel extends DiscordBase_1.DiscordBase {
@@ -103,13 +102,13 @@ class BaseGuildChannel extends BaseChannel {
103
102
  values: () => (this.guildId ? this.client.cache.overwrites?.values(this.guildId) ?? [] : []),
104
103
  };
105
104
  memberPermissions(member, checkAdmin = true) {
106
- return this.client.channels.overwrites.memberPermissions(this.id, member, checkAdmin);
105
+ return this.client.channels.memberPermissions(this.id, member, checkAdmin);
107
106
  }
108
107
  rolePermissions(role, checkAdmin = true) {
109
- return this.client.channels.overwrites.rolePermissions(this.id, role, checkAdmin);
108
+ return this.client.channels.rolePermissions(this.id, role, checkAdmin);
110
109
  }
111
110
  overwritesFor(member) {
112
- return this.client.channels.overwrites.overwritesFor(this.id, member);
111
+ return this.client.channels.overwritesFor(this.id, member);
113
112
  }
114
113
  guild(force = false) {
115
114
  return this.client.guilds.fetch(this.guildId, force);
@@ -147,17 +146,17 @@ class MessagesMethods extends DiscordBase_1.DiscordBase {
147
146
  }
148
147
  static reactions(ctx) {
149
148
  return {
150
- add: (messageId, emoji) => ctx.client.messages.reactions.add(messageId, ctx.channelId, emoji),
151
- delete: (messageId, emoji, userId = '@me') => ctx.client.messages.reactions.delete(messageId, ctx.channelId, emoji, userId),
152
- fetch: (messageId, emoji, query) => ctx.client.messages.reactions.fetch(messageId, ctx.channelId, emoji, query),
153
- purge: (messageId, emoji) => ctx.client.messages.reactions.purge(messageId, ctx.channelId, emoji),
149
+ add: (messageId, emoji) => ctx.client.reactions.add(messageId, ctx.channelId, emoji),
150
+ delete: (messageId, emoji, userId = '@me') => ctx.client.reactions.delete(messageId, ctx.channelId, emoji, userId),
151
+ fetch: (messageId, emoji, query) => ctx.client.reactions.fetch(messageId, ctx.channelId, emoji, query),
152
+ purge: (messageId, emoji) => ctx.client.reactions.purge(messageId, ctx.channelId, emoji),
154
153
  };
155
154
  }
156
155
  static pins(ctx) {
157
156
  return {
158
- fetch: () => ctx.client.channels.pins.fetch(ctx.channelId),
159
- set: (messageId, reason) => ctx.client.channels.pins.set(messageId, ctx.channelId, reason),
160
- delete: (messageId, reason) => ctx.client.channels.pins.delete(messageId, ctx.channelId, reason),
157
+ fetch: () => ctx.client.channels.pins(ctx.channelId),
158
+ set: (messageId, reason) => ctx.client.channels.setPin(messageId, ctx.channelId, reason),
159
+ delete: (messageId, reason) => ctx.client.channels.deletePin(messageId, ctx.channelId, reason),
161
160
  };
162
161
  }
163
162
  static transformMessageBody(body) {
@@ -254,10 +253,7 @@ class WebhookGuildMethods extends DiscordBase_1.DiscordBase {
254
253
  webhooks = WebhookGuildMethods.guild({ client: this.client, guildId: this.id });
255
254
  static guild(ctx) {
256
255
  return {
257
- list: async () => {
258
- const webhooks = await ctx.client.proxy.guilds(ctx.guildId).webhooks.get();
259
- return webhooks.map(webhook => new Webhook_1.Webhook(ctx.client, webhook));
260
- },
256
+ list: () => ctx.client.webhooks.listFromChannel(ctx.guildId),
261
257
  };
262
258
  }
263
259
  }
@@ -266,16 +262,8 @@ class WebhookChannelMethods extends DiscordBase_1.DiscordBase {
266
262
  webhooks = WebhookChannelMethods.channel({ client: this.client, channelId: this.id });
267
263
  static channel(ctx) {
268
264
  return {
269
- list: async () => {
270
- const webhooks = await ctx.client.proxy.channels(ctx.channelId).webhooks.get();
271
- return webhooks.map(webhook => new Webhook_1.Webhook(ctx.client, webhook));
272
- },
273
- create: async (body) => {
274
- const webhook = await ctx.client.proxy.channels(ctx.channelId).webhooks.post({
275
- body,
276
- });
277
- return new Webhook_1.Webhook(ctx.client, webhook);
278
- },
265
+ list: () => ctx.client.webhooks.listFromChannel(ctx.channelId),
266
+ create: async (body) => ctx.client.webhooks.create(ctx.channelId, body),
279
267
  };
280
268
  }
281
269
  }
@@ -1,7 +1,6 @@
1
- import type { BaseClient } from '../../client/base';
2
1
  import type { UsingClient } from '../../commands';
3
2
  /** */
4
3
  export declare abstract class Base {
5
- constructor(client: BaseClient);
4
+ constructor(client: UsingClient);
6
5
  readonly client: UsingClient;
7
6
  }
@@ -1,10 +1,10 @@
1
- import type { BaseClient } from '../../client/base';
1
+ import type { UsingClient } from '../../commands';
2
2
  import { Base } from './Base';
3
3
  export declare class DiscordBase<Data extends Record<string, any> = {
4
4
  id: string;
5
5
  }> extends Base {
6
6
  id: string;
7
- constructor(client: BaseClient,
7
+ constructor(client: UsingClient,
8
8
  /** Unique ID of the object */
9
9
  data: Data);
10
10
  /**
@@ -16,6 +16,7 @@ const ShardManagerDefaults = {
16
16
  intents: 0,
17
17
  properties,
18
18
  version: 10,
19
+ shardStart: 0,
19
20
  handlePayload: (shardId, packet) => {
20
21
  console.info(`Packet ${packet.t} on shard ${shardId}`);
21
22
  },
@@ -42,7 +42,9 @@ class Shard {
42
42
  });
43
43
  }
44
44
  get latency() {
45
- return this.heart.lastAck && this.heart.lastBeat ? this.heart.lastAck - this.heart.lastBeat : Infinity;
45
+ return this.heart.lastAck && this.heart.lastBeat
46
+ ? this.heart.lastAck - this.heart.lastBeat
47
+ : Number.POSITIVE_INFINITY;
46
48
  }
47
49
  get isOpen() {
48
50
  return this.websocket?.readyState === ws_1.WebSocket.OPEN;
@@ -94,7 +96,7 @@ class Shard {
94
96
  d: {
95
97
  token: `Bot ${this.options.token}`,
96
98
  compress: this.options.compress,
97
- properties: constants_1.properties,
99
+ properties: this.options.properties ?? constants_1.properties,
98
100
  shard: [this.id, this.options.info.shards],
99
101
  intents: this.options.intents,
100
102
  presence: this.options.presence,
@@ -7,6 +7,9 @@ export declare class ShardManager extends Map<number, Shard> {
7
7
  options: ShardManagerOptions;
8
8
  debugger?: Logger;
9
9
  constructor(options: ShardManagerOptions);
10
+ get totalShards(): number;
11
+ get shardStart(): number;
12
+ get shardEnd(): number;
10
13
  get remaining(): number;
11
14
  get concurrency(): number;
12
15
  get latency(): number;
@@ -23,6 +23,15 @@ class ShardManager extends Map {
23
23
  });
24
24
  }
25
25
  }
26
+ get totalShards() {
27
+ return this.options.totalShards ?? this.options.info.shards;
28
+ }
29
+ get shardStart() {
30
+ return this.options.shardStart ?? 0;
31
+ }
32
+ get shardEnd() {
33
+ return this.options.shardEnd ?? this.totalShards;
34
+ }
26
35
  get remaining() {
27
36
  return this.options.info.session_start_limit.remaining;
28
37
  }
@@ -43,7 +52,7 @@ class ShardManager extends Map {
43
52
  shard ??= new shard_js_1.Shard(shardId, {
44
53
  token: this.options.token,
45
54
  intents: this.options.intents,
46
- info: { ...this.options.info, shards: (this.options.shardEnd ?? this.options.totalShards) },
55
+ info: { ...this.options.info, shards: this.totalShards },
47
56
  handlePayload: this.options.handlePayload,
48
57
  properties: this.options.properties,
49
58
  debugger: this.debugger,
@@ -72,12 +81,10 @@ class ShardManager extends Map {
72
81
  */
73
82
  spawnBuckets() {
74
83
  this.debugger?.info('#0 Preparing buckets');
75
- const chunks = structures_1.SequentialBucket.chunk(new Array(this.options.shardStart !== undefined && this.options.shardEnd !== undefined
76
- ? this.options.shardEnd - this.options.shardStart
77
- : this.options.totalShards), this.concurrency);
84
+ const chunks = structures_1.SequentialBucket.chunk(new Array(this.shardEnd - this.shardStart), this.concurrency);
78
85
  chunks.forEach((arr, index) => {
79
86
  for (let i = 0; i < arr.length; i++) {
80
- const id = i + (index > 0 ? index * this.concurrency : 0) + (this.options.shardStart ?? 0);
87
+ const id = i + (index > 0 ? index * this.concurrency : 0) + this.shardStart;
81
88
  chunks[index][i] = this.spawn(id);
82
89
  }
83
90
  });
@@ -30,6 +30,7 @@ export interface ShardManagerOptions extends ShardDetails {
30
30
  compress?: boolean;
31
31
  }
32
32
  export interface WorkerManagerOptions extends Omit<ShardManagerOptions, 'handlePayload'> {
33
+ mode: 'threads' | 'clusters';
33
34
  workers?: number;
34
35
  /**
35
36
  * @default 32
@@ -35,6 +35,7 @@ export type WorkerSendInfo = CreateWorkerMessage<'WORKER_INFO', WorkerInfo & {
35
35
  nonce: string;
36
36
  }>;
37
37
  export type WorkerReady = CreateWorkerMessage<'WORKER_READY'>;
38
+ export type WorkerStart = CreateWorkerMessage<'WORKER_START'>;
38
39
  export type WorkerSendApiRequest = CreateWorkerMessage<'WORKER_API_REQUEST', {
39
40
  method: HttpMethods;
40
41
  url: `/${string}`;
@@ -55,5 +56,5 @@ export type WorkerSendEval = CreateWorkerMessage<'EVAL', {
55
56
  nonce: string;
56
57
  toWorkerId: number;
57
58
  }>;
58
- export type WorkerMessage = WorkerRequestConnect | WorkerReceivePayload | WorkerSendResultPayload | WorkerSendCacheRequest | WorkerSendShardInfo | WorkerSendInfo | WorkerReady | WorkerSendApiRequest | WorkerExecuteEval | WorkerSendEvalResponse | WorkerSendEval;
59
+ export type WorkerMessage = WorkerRequestConnect | WorkerReceivePayload | WorkerSendResultPayload | WorkerSendCacheRequest | WorkerSendShardInfo | WorkerSendInfo | WorkerReady | WorkerSendApiRequest | WorkerExecuteEval | WorkerSendEvalResponse | WorkerSendEval | WorkerStart;
59
60
  export {};
@@ -4,7 +4,9 @@
4
4
  /// <reference types="node" />
5
5
  /// <reference types="node" />
6
6
  /// <reference types="node" />
7
- import { Worker } from 'node:worker_threads';
7
+ /// <reference types="node" />
8
+ import { type Worker as ClusterWorker } from 'node:cluster';
9
+ import { Worker as ThreadWorker } from 'node:worker_threads';
8
10
  import { ApiHandler } from '../..';
9
11
  import { type Adapter } from '../../cache';
10
12
  import { Logger, type GatewayPresenceUpdateData, type GatewaySendPayload, type MakePartial } from '../../common';
@@ -13,7 +15,7 @@ import { MemberUpdateHandler } from './events/memberUpdate';
13
15
  import { PresenceUpdateHandler } from './events/presenceUpdate';
14
16
  import type { ShardOptions, WorkerData, WorkerManagerOptions } from './shared';
15
17
  import type { WorkerInfo, WorkerMessage, WorkerShardInfo } from './worker';
16
- export declare class WorkerManager extends Map<number, Worker & {
18
+ export declare class WorkerManager extends Map<number, (ClusterWorker | ThreadWorker) & {
17
19
  ready?: boolean;
18
20
  }> {
19
21
  options: Required<WorkerManagerOptions>;
@@ -34,6 +36,8 @@ export declare class WorkerManager extends Map<number, Worker & {
34
36
  get concurrency(): number;
35
37
  get totalWorkers(): number;
36
38
  get totalShards(): number;
39
+ get shardStart(): number;
40
+ get shardEnd(): number;
37
41
  get shardsPerWorker(): number;
38
42
  get workers(): number;
39
43
  syncLatency({ shardId, workerId }: {
@@ -43,8 +47,9 @@ export declare class WorkerManager extends Map<number, Worker & {
43
47
  calculateShardId(guildId: string): number;
44
48
  calculateWorkerId(shardId: number): number;
45
49
  prepareSpaces(): number[][];
50
+ postMessage(id: number, body: any): void;
46
51
  prepareWorkers(shards: number[][]): Promise<void>;
47
- createWorker(workerData: WorkerData): Worker;
52
+ createWorker(workerData: WorkerData): ClusterWorker | ThreadWorker;
48
53
  spawn(workerId: number, shardId: number): void;
49
54
  handleWorkerMessage(message: WorkerMessage): Promise<void>;
50
55
  private generateNonce;