seyfert 1.3.3 → 1.5.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 (138) hide show
  1. package/README.md +7 -7
  2. package/lib/api/Router.js +3 -1
  3. package/lib/api/Routes/guilds.d.ts +4 -1
  4. package/lib/api/api.js +13 -7
  5. package/lib/builders/Attachment.d.ts +1 -4
  6. package/lib/builders/Attachment.js +4 -4
  7. package/lib/cache/adapters/workeradapter.js +7 -3
  8. package/lib/cache/index.d.ts +6 -2
  9. package/lib/cache/index.js +18 -0
  10. package/lib/cache/resources/bans.d.ts +12 -0
  11. package/lib/cache/resources/bans.js +35 -0
  12. package/lib/cache/resources/default/base.d.ts +1 -2
  13. package/lib/cache/resources/default/guild-based.d.ts +1 -2
  14. package/lib/cache/resources/members.js +4 -4
  15. package/lib/cache/resources/messages.js +8 -6
  16. package/lib/client/base.d.ts +33 -7
  17. package/lib/client/base.js +80 -21
  18. package/lib/client/client.d.ts +18 -6
  19. package/lib/client/client.js +45 -37
  20. package/lib/client/collectors.d.ts +36 -0
  21. package/lib/client/collectors.js +85 -0
  22. package/lib/client/httpclient.d.ts +7 -8
  23. package/lib/client/httpclient.js +96 -17
  24. package/lib/client/oninteractioncreate.d.ts +2 -2
  25. package/lib/client/oninteractioncreate.js +15 -7
  26. package/lib/client/onmessagecreate.d.ts +12 -2
  27. package/lib/client/onmessagecreate.js +105 -82
  28. package/lib/client/workerclient.d.ts +5 -2
  29. package/lib/client/workerclient.js +66 -63
  30. package/lib/collection.d.ts +2 -2
  31. package/lib/collection.js +2 -2
  32. package/lib/commands/applications/chat.d.ts +11 -10
  33. package/lib/commands/applications/chat.js +23 -8
  34. package/lib/commands/applications/chatcontext.d.ts +1 -1
  35. package/lib/commands/applications/chatcontext.js +2 -2
  36. package/lib/commands/applications/menu.d.ts +8 -7
  37. package/lib/commands/applications/menu.js +3 -50
  38. package/lib/commands/applications/menucontext.d.ts +1 -1
  39. package/lib/commands/applications/menucontext.js +3 -3
  40. package/lib/commands/applications/options.d.ts +3 -1
  41. package/lib/commands/applications/shared.d.ts +12 -0
  42. package/lib/commands/basecontext.d.ts +26 -0
  43. package/lib/commands/{basecontex.js → basecontext.js} +24 -0
  44. package/lib/commands/decorators.d.ts +11 -17
  45. package/lib/commands/decorators.js +7 -14
  46. package/lib/commands/handler.d.ts +6 -1
  47. package/lib/commands/handler.js +161 -29
  48. package/lib/common/bot/watcher.d.ts +1 -2
  49. package/lib/common/bot/watcher.js +9 -4
  50. package/lib/common/index.d.ts +1 -0
  51. package/lib/common/index.js +3 -1
  52. package/lib/common/it/formatter.d.ts +155 -0
  53. package/lib/common/it/formatter.js +184 -0
  54. package/lib/common/it/logger.d.ts +1 -1
  55. package/lib/common/it/logger.js +14 -13
  56. package/lib/common/it/utils.d.ts +2 -0
  57. package/lib/common/it/utils.js +21 -9
  58. package/lib/common/shorters/bans.d.ts +43 -0
  59. package/lib/common/shorters/bans.js +78 -0
  60. package/lib/common/shorters/emojis.d.ts +1 -1
  61. package/lib/common/shorters/emojis.js +4 -3
  62. package/lib/common/shorters/interaction.js +9 -7
  63. package/lib/common/shorters/messages.js +2 -2
  64. package/lib/common/shorters/webhook.js +2 -2
  65. package/lib/components/componentcommand.d.ts +22 -0
  66. package/lib/components/{command.js → componentcommand.js} +3 -5
  67. package/lib/components/componentcontext.d.ts +20 -16
  68. package/lib/components/componentcontext.js +27 -9
  69. package/lib/components/handler.d.ts +11 -6
  70. package/lib/components/handler.js +106 -32
  71. package/lib/components/index.d.ts +3 -1
  72. package/lib/components/index.js +3 -1
  73. package/lib/components/modalcommand.d.ts +16 -0
  74. package/lib/components/modalcommand.js +10 -0
  75. package/lib/components/modalcontext.d.ts +104 -0
  76. package/lib/components/modalcontext.js +132 -0
  77. package/lib/events/event.d.ts +4 -3
  78. package/lib/events/handler.d.ts +12 -6
  79. package/lib/events/handler.js +60 -20
  80. package/lib/events/hooks/application_command.d.ts +2 -2
  81. package/lib/events/hooks/auto_moderation.d.ts +5 -5
  82. package/lib/events/hooks/channel.d.ts +5 -5
  83. package/lib/events/hooks/custom.d.ts +3 -3
  84. package/lib/events/hooks/dispatch.d.ts +4 -4
  85. package/lib/events/hooks/entitlement.d.ts +4 -4
  86. package/lib/events/hooks/guild.d.ts +41 -96
  87. package/lib/events/hooks/guild.js +6 -6
  88. package/lib/events/hooks/integration.d.ts +61 -4
  89. package/lib/events/hooks/interactions.d.ts +2 -2
  90. package/lib/events/hooks/invite.d.ts +6 -3
  91. package/lib/events/hooks/message.d.ts +23 -18
  92. package/lib/events/hooks/message.js +1 -1
  93. package/lib/events/hooks/presence.d.ts +11 -3
  94. package/lib/events/hooks/presence.js +2 -2
  95. package/lib/events/hooks/stage.d.ts +7 -13
  96. package/lib/events/hooks/stage.js +2 -2
  97. package/lib/events/hooks/thread.d.ts +21 -10
  98. package/lib/events/hooks/thread.js +2 -2
  99. package/lib/events/hooks/typing.d.ts +3 -2
  100. package/lib/events/hooks/user.d.ts +2 -2
  101. package/lib/events/hooks/user.js +2 -2
  102. package/lib/events/hooks/voice.d.ts +5 -45
  103. package/lib/events/hooks/voice.js +4 -7
  104. package/lib/events/hooks/webhook.d.ts +2 -2
  105. package/lib/index.d.ts +4 -4
  106. package/lib/index.js +11 -5
  107. package/lib/langs/handler.d.ts +4 -1
  108. package/lib/langs/handler.js +3 -3
  109. package/lib/structures/Guild.d.ts +9 -1
  110. package/lib/structures/Guild.js +2 -0
  111. package/lib/structures/GuildBan.d.ts +25 -0
  112. package/lib/structures/GuildBan.js +36 -0
  113. package/lib/structures/GuildEmoji.d.ts +1 -1
  114. package/lib/structures/GuildMember.d.ts +7 -2
  115. package/lib/structures/GuildMember.js +4 -4
  116. package/lib/structures/Interaction.d.ts +4 -3
  117. package/lib/structures/Interaction.js +29 -12
  118. package/lib/structures/Message.d.ts +69 -8
  119. package/lib/structures/Message.js +59 -17
  120. package/lib/structures/Sticker.d.ts +3 -3
  121. package/lib/structures/User.d.ts +1 -0
  122. package/lib/structures/User.js +4 -1
  123. package/lib/structures/VoiceState.d.ts +6 -5
  124. package/lib/structures/VoiceState.js +6 -3
  125. package/lib/structures/channels.d.ts +4 -1
  126. package/lib/structures/channels.js +37 -6
  127. package/lib/structures/extra/functions.js +1 -1
  128. package/lib/websocket/discord/basesocket.d.ts +1 -0
  129. package/lib/websocket/discord/basesocket.js +17 -0
  130. package/lib/websocket/discord/shard.d.ts +1 -0
  131. package/lib/websocket/discord/shard.js +6 -0
  132. package/lib/websocket/discord/sharder.js +10 -3
  133. package/lib/websocket/discord/shared.d.ts +1 -0
  134. package/lib/websocket/discord/workermanager.d.ts +2 -3
  135. package/lib/websocket/discord/workermanager.js +4 -2
  136. package/package.json +7 -7
  137. package/lib/commands/basecontex.d.ts +0 -15
  138. package/lib/components/command.d.ts +0 -24
@@ -1,7 +1,7 @@
1
- import type { APIChannelMention, APIMessage, GatewayMessageCreateDispatchData } from 'discord-api-types/v10';
1
+ import type { APIChannelMention, APIEmbed, APIMessage, GatewayMessageCreateDispatchData } from 'discord-api-types/v10';
2
2
  import type { ListenerOptions } from '../builders';
3
3
  import type { UsingClient } from '../commands';
4
- import type { ObjectToLower } from '../common';
4
+ import { type ObjectToLower } from '../common';
5
5
  import type { EmojiResolvable } from '../common/types/resolvables';
6
6
  import type { MessageCreateBodyRequest, MessageUpdateBodyRequest } from '../common/types/write';
7
7
  import type { ActionRowMessageComponents } from '../components';
@@ -10,13 +10,11 @@ import { GuildMember } from './GuildMember';
10
10
  import { User } from './User';
11
11
  import type { MessageWebhookMethodEditParams, MessageWebhookMethodWriteParams } from './Webhook';
12
12
  import { DiscordBase } from './extra/DiscordBase';
13
- import { Poll } from '..';
13
+ import { Embed, Poll } from '..';
14
14
  export type MessageData = APIMessage | GatewayMessageCreateDispatchData;
15
- export interface BaseMessage extends DiscordBase, ObjectToLower<Omit<MessageData, 'timestamp' | 'author' | 'mentions' | 'components' | 'poll'>> {
16
- }
17
- export declare class BaseMessage extends DiscordBase {
18
- guildId: string | undefined;
15
+ export interface BaseMessage extends DiscordBase, ObjectToLower<Omit<MessageData, 'timestamp' | 'author' | 'mentions' | 'components' | 'poll' | 'embeds'>> {
19
16
  timestamp?: number;
17
+ guildId?: string;
20
18
  author: User;
21
19
  member?: GuildMember;
22
20
  components: MessageActionRowComponent<ActionRowMessageComponents>[];
@@ -26,6 +24,9 @@ export declare class BaseMessage extends DiscordBase {
26
24
  channels: APIChannelMention[];
27
25
  users: (GuildMember | User)[];
28
26
  };
27
+ }
28
+ export declare class BaseMessage extends DiscordBase {
29
+ embeds: InMessageEmbed[];
29
30
  constructor(client: UsingClient, data: MessageData);
30
31
  get user(): User;
31
32
  createComponentCollector(options?: ListenerOptions): {
@@ -38,7 +39,7 @@ export declare class BaseMessage extends DiscordBase {
38
39
  react(emoji: EmojiResolvable): Promise<void>;
39
40
  private patch;
40
41
  }
41
- export interface Message extends BaseMessage, ObjectToLower<Omit<MessageData, 'timestamp' | 'author' | 'mentions' | 'components' | 'poll'>> {
42
+ export interface Message extends BaseMessage, ObjectToLower<Omit<MessageData, 'timestamp' | 'author' | 'mentions' | 'components' | 'poll' | 'embeds'>> {
42
43
  }
43
44
  export declare class Message extends BaseMessage {
44
45
  constructor(client: UsingClient, data: MessageData);
@@ -60,3 +61,63 @@ export declare class WebhookMessage extends BaseMessage {
60
61
  write(body: WriteMessageWebhook): Promise<WebhookMessage | null>;
61
62
  delete(reason?: string): Promise<never>;
62
63
  }
64
+ export declare class InMessageEmbed {
65
+ data: APIEmbed;
66
+ constructor(data: APIEmbed);
67
+ get title(): string | undefined;
68
+ /**
69
+ * @deprecated
70
+ */
71
+ get type(): import("discord-api-types/v10").EmbedType | undefined;
72
+ get description(): string | undefined;
73
+ get url(): string | undefined;
74
+ get timestamp(): string | undefined;
75
+ get color(): number | undefined;
76
+ get footer(): {
77
+ text: string;
78
+ iconUrl?: string | undefined;
79
+ proxyIconUrl?: string | undefined;
80
+ } | undefined;
81
+ get image(): {
82
+ url: string;
83
+ proxyUrl?: string | undefined;
84
+ height?: number | undefined;
85
+ width?: number | undefined;
86
+ } | undefined;
87
+ get thumbnail(): {
88
+ url: string;
89
+ proxyUrl?: string | undefined;
90
+ height?: number | undefined;
91
+ width?: number | undefined;
92
+ } | undefined;
93
+ get video(): {
94
+ url?: string | undefined;
95
+ proxyUrl?: string | undefined;
96
+ height?: number | undefined;
97
+ width?: number | undefined;
98
+ } | undefined;
99
+ get provider(): import("discord-api-types/v10").APIEmbedProvider | undefined;
100
+ get author(): {
101
+ name: string;
102
+ url?: string | undefined;
103
+ iconUrl?: string | undefined;
104
+ proxyIconUrl?: string | undefined;
105
+ } | undefined;
106
+ get fields(): import("discord-api-types/v10").APIEmbedField[] | undefined;
107
+ toBuilder(): Embed;
108
+ toJSON(): {
109
+ title?: string | undefined;
110
+ type?: import("discord-api-types/v10").EmbedType | undefined;
111
+ description?: string | undefined;
112
+ url?: string | undefined;
113
+ timestamp?: string | undefined;
114
+ color?: number | undefined;
115
+ footer?: import("discord-api-types/v10").APIEmbedFooter | undefined;
116
+ image?: import("discord-api-types/v10").APIEmbedImage | undefined;
117
+ thumbnail?: import("discord-api-types/v10").APIEmbedThumbnail | undefined;
118
+ video?: import("discord-api-types/v10").APIEmbedVideo | undefined;
119
+ provider?: import("discord-api-types/v10").APIEmbedProvider | undefined;
120
+ author?: import("discord-api-types/v10").APIEmbedAuthor | undefined;
121
+ fields?: import("discord-api-types/v10").APIEmbedField[] | undefined;
122
+ };
123
+ }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebhookMessage = exports.Message = exports.BaseMessage = void 0;
3
+ exports.InMessageEmbed = exports.WebhookMessage = exports.Message = exports.BaseMessage = void 0;
4
+ const common_1 = require("../common");
4
5
  const ActionRow_1 = require("../components/ActionRow");
5
6
  const GuildMember_1 = require("./GuildMember");
6
7
  const User_1 = require("./User");
@@ -8,13 +9,7 @@ const DiscordBase_1 = require("./extra/DiscordBase");
8
9
  const functions_1 = require("./extra/functions");
9
10
  const __1 = require("..");
10
11
  class BaseMessage extends DiscordBase_1.DiscordBase {
11
- guildId;
12
- timestamp;
13
- author;
14
- member;
15
- components;
16
- poll;
17
- mentions;
12
+ embeds;
18
13
  constructor(client, data) {
19
14
  super(client, data);
20
15
  this.mentions = {
@@ -23,6 +18,7 @@ class BaseMessage extends DiscordBase_1.DiscordBase {
23
18
  users: [],
24
19
  };
25
20
  this.components = data.components?.map(x => new ActionRow_1.MessageActionRowComponent(x)) ?? [];
21
+ this.embeds = data.embeds.map(embed => new InMessageEmbed(embed));
26
22
  this.patch(data);
27
23
  }
28
24
  get user() {
@@ -46,18 +42,9 @@ class BaseMessage extends DiscordBase_1.DiscordBase {
46
42
  return this.client.reactions.add(this.id, this.channelId, emoji);
47
43
  }
48
44
  patch(data) {
49
- if ('guild_id' in data) {
50
- this.guildId = data.guild_id;
51
- }
52
- if (data.type !== undefined) {
53
- this.type = data.type;
54
- }
55
45
  if ('timestamp' in data && data.timestamp) {
56
46
  this.timestamp = Date.parse(data.timestamp);
57
47
  }
58
- if ('application_id' in data) {
59
- this.applicationId = data.application_id;
60
- }
61
48
  if ('author' in data && data.author) {
62
49
  this.author = new User_1.User(this.client, data.author);
63
50
  }
@@ -141,3 +128,58 @@ class WebhookMessage extends BaseMessage {
141
128
  }
142
129
  }
143
130
  exports.WebhookMessage = WebhookMessage;
131
+ class InMessageEmbed {
132
+ data;
133
+ constructor(data) {
134
+ this.data = data;
135
+ }
136
+ get title() {
137
+ return this.data.title;
138
+ }
139
+ /**
140
+ * @deprecated
141
+ */
142
+ get type() {
143
+ return this.data.type;
144
+ }
145
+ get description() {
146
+ return this.data.description;
147
+ }
148
+ get url() {
149
+ return this.data.url;
150
+ }
151
+ get timestamp() {
152
+ return this.data.timestamp;
153
+ }
154
+ get color() {
155
+ return this.data.color;
156
+ }
157
+ get footer() {
158
+ return this.data.footer ? (0, common_1.toCamelCase)(this.data.footer) : undefined;
159
+ }
160
+ get image() {
161
+ return this.data.image ? (0, common_1.toCamelCase)(this.data.image) : undefined;
162
+ }
163
+ get thumbnail() {
164
+ return this.data.thumbnail ? (0, common_1.toCamelCase)(this.data.thumbnail) : undefined;
165
+ }
166
+ get video() {
167
+ return this.data.video ? (0, common_1.toCamelCase)(this.data.video) : undefined;
168
+ }
169
+ get provider() {
170
+ return this.data.provider;
171
+ }
172
+ get author() {
173
+ return this.data.author ? (0, common_1.toCamelCase)(this.data.author) : undefined;
174
+ }
175
+ get fields() {
176
+ return this.data.fields;
177
+ }
178
+ toBuilder() {
179
+ return new __1.Embed(this.data);
180
+ }
181
+ toJSON() {
182
+ return { ...this.data };
183
+ }
184
+ }
185
+ exports.InMessageEmbed = InMessageEmbed;
@@ -1,6 +1,6 @@
1
1
  import type { APISticker, RESTPatchAPIGuildStickerJSONBody, RESTPostAPIGuildStickerFormDataBody } from 'discord-api-types/v10';
2
- import type { UsingClient } from '..';
3
- import type { Attachment } from '../builders';
2
+ import type { RawFile, UsingClient } from '..';
3
+ import type { Attachment, AttachmentBuilder } from '../builders';
4
4
  import type { MethodContext, ObjectToLower } from '../common';
5
5
  import { User } from './User';
6
6
  import { DiscordBase } from './extra/DiscordBase';
@@ -24,5 +24,5 @@ export declare class Sticker extends DiscordBase {
24
24
  };
25
25
  }
26
26
  export interface CreateStickerBodyRequest extends Omit<RESTPostAPIGuildStickerFormDataBody, 'file'> {
27
- file: Attachment;
27
+ file: Attachment | AttachmentBuilder | RawFile;
28
28
  }
@@ -16,6 +16,7 @@ export declare class User extends DiscordBase<APIUser> {
16
16
  */
17
17
  dm(force?: boolean): Promise<import("./channels").DMChannel>;
18
18
  write(body: MessageCreateBodyRequest): Promise<import("./Message").Message>;
19
+ defaultAvatarURL(): string;
19
20
  avatarURL(options?: ImageOptions): string;
20
21
  avatarDecorationURL(options?: ImageOptions): string | undefined;
21
22
  bannerURL(options?: ImageOptions): string | undefined;
@@ -25,9 +25,12 @@ class User extends DiscordBase_1.DiscordBase {
25
25
  write(body) {
26
26
  return this.client.users.write(this.id, body);
27
27
  }
28
+ defaultAvatarURL() {
29
+ return this.rest.cdn.embed.avatars.get((0, api_1.calculateUserDefaultAvatarIndex)(this.id, this.discriminator));
30
+ }
28
31
  avatarURL(options) {
29
32
  if (!this.avatar) {
30
- return this.rest.cdn.embed.avatars.get((0, api_1.calculateUserDefaultAvatarIndex)(this.id, this.discriminator));
33
+ return this.defaultAvatarURL();
31
34
  }
32
35
  return this.rest.cdn.avatars(this.id).get(this.avatar, options);
33
36
  }
@@ -1,16 +1,17 @@
1
- import type { GuildMember, UsingClient } from '../';
1
+ import { GuildMember, type UsingClient } from '../';
2
2
  import type { VoiceStateResource } from '../cache/resources/voice-states';
3
3
  import type { ObjectToLower } from '../common';
4
+ import type { GatewayVoiceState } from '../types';
4
5
  import { Base } from './extra/Base';
5
- export interface VoiceState extends Base, ObjectToLower<VoiceStateResource> {
6
+ export interface VoiceState extends Base, ObjectToLower<Omit<VoiceStateResource, 'member'>> {
6
7
  }
7
8
  export declare class VoiceState extends Base {
8
- private withMember?;
9
- constructor(client: UsingClient, data: VoiceStateResource, withMember?: GuildMember | undefined);
9
+ protected withMember?: GuildMember;
10
+ constructor(client: UsingClient, data: GatewayVoiceState);
10
11
  isMuted(): boolean;
11
12
  member(force?: boolean): Promise<GuildMember>;
12
13
  user(force?: boolean): Promise<import("./User").User>;
13
- channel(force?: boolean): Promise<import("./channels").BaseChannel<import("discord-api-types/v10").ChannelType> | import("./channels").DMChannel | import("./channels").CategoryChannel | undefined>;
14
+ channel(force?: boolean): Promise<import("./channels").BaseChannel<import("discord-api-types/payloads/v10/channel").ChannelType> | import("./channels").DMChannel | import("./channels").CategoryChannel | undefined>;
14
15
  setMute(mute?: boolean, reason?: string): Promise<GuildMember>;
15
16
  setDeaf(deaf?: boolean, reason?: string): Promise<GuildMember>;
16
17
  disconnect(reason?: string): Promise<GuildMember>;
@@ -1,13 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VoiceState = void 0;
4
+ const __1 = require("../");
4
5
  const Base_1 = require("./extra/Base");
5
6
  class VoiceState extends Base_1.Base {
6
7
  withMember;
7
- constructor(client, data, withMember) {
8
+ constructor(client, data) {
8
9
  super(client);
9
- this.withMember = withMember;
10
- this.__patchThis(data);
10
+ const { member, ...rest } = data;
11
+ this.__patchThis(rest);
12
+ if (member?.user && data.guild_id)
13
+ this.withMember = new __1.GuildMember(client, member, member.user, data.guild_id);
11
14
  }
12
15
  isMuted() {
13
16
  return this.mute || this.selfMute;
@@ -4,6 +4,7 @@ import type { EmojiResolvable, MessageCreateBodyRequest, MessageUpdateBodyReques
4
4
  import type { GuildMember } from './GuildMember';
5
5
  import type { GuildRole } from './GuildRole';
6
6
  import { DiscordBase } from './extra/DiscordBase';
7
+ import { Collection, type RawFile } from '..';
7
8
  export declare class BaseChannel<T extends ChannelType> extends DiscordBase<APIChannelBase<ChannelType>> {
8
9
  type: T;
9
10
  constructor(client: UsingClient, data: APIChannelBase<ChannelType>);
@@ -153,7 +154,7 @@ export declare class MessagesMethods extends DiscordBase {
153
154
  set: (messageId: string, reason?: string) => Promise<never>;
154
155
  delete: (messageId: string, reason?: string) => Promise<never>;
155
156
  };
156
- static transformMessageBody<T>(body: MessageCreateBodyRequest | MessageUpdateBodyRequest): T;
157
+ static transformMessageBody<T>(body: MessageCreateBodyRequest | MessageUpdateBodyRequest, files: RawFile[] | undefined, self: UsingClient): T;
157
158
  }
158
159
  export interface TextBaseGuildChannel extends ObjectToLower<Omit<APITextChannel, 'type' | 'permission_overwrites'>>, MessagesMethods {
159
160
  }
@@ -185,6 +186,7 @@ export declare class VoiceChannelMethods extends DiscordBase {
185
186
  setVideoQuality(quality: keyof typeof VideoQualityMode, reason?: string): Promise<AllChannels>;
186
187
  setVoiceState(status?: string | null): Promise<never>;
187
188
  states(): Promise<import("./VoiceState").VoiceState[]>;
189
+ members(force?: boolean): Promise<Collection<string, GuildMember>>;
188
190
  }
189
191
  export declare class WebhookGuildMethods extends DiscordBase {
190
192
  webhooks: {
@@ -277,5 +279,6 @@ export declare class DirectoryChannel extends BaseChannel<ChannelType.GuildDirec
277
279
  export type AllGuildChannels = TextGuildChannel | VoiceChannel | MediaChannel | ForumChannel | ThreadChannel | CategoryChannel | NewsChannel | DirectoryChannel | StageChannel;
278
280
  export type AllTextableChannels = TextGuildChannel | VoiceChannel | DMChannel | NewsChannel | ThreadChannel;
279
281
  export type AllGuildTextableChannels = TextGuildChannel | VoiceChannel | NewsChannel | ThreadChannel;
282
+ export type AllGuildVoiceChannels = VoiceChannel | StageChannel;
280
283
  export type AllChannels = BaseChannel<ChannelType> | BaseGuildChannel | TextGuildChannel | DMChannel | VoiceChannel | MediaChannel | ForumChannel | ThreadChannel | CategoryChannel | NewsChannel | DirectoryChannel | StageChannel;
281
284
  export {};
@@ -12,6 +12,7 @@ const ts_mixer_1 = require("ts-mixer");
12
12
  const builders_1 = require("../builders");
13
13
  const DiscordBase_1 = require("./extra/DiscordBase");
14
14
  const functions_1 = require("./extra/functions");
15
+ const __1 = require("..");
15
16
  class BaseChannel extends DiscordBase_1.DiscordBase {
16
17
  constructor(client, data) {
17
18
  super(client, data);
@@ -131,9 +132,15 @@ class MessagesMethods extends DiscordBase_1.DiscordBase {
131
132
  typing() {
132
133
  return this.client.channels.typing(this.id);
133
134
  }
134
- messages = MessagesMethods.messages({ client: this.client, channelId: this.id });
135
+ messages = MessagesMethods.messages({
136
+ client: this.client,
137
+ channelId: this.id,
138
+ });
135
139
  pins = MessagesMethods.pins({ client: this.client, channelId: this.id });
136
- reactions = MessagesMethods.reactions({ client: this.client, channelId: this.id });
140
+ reactions = MessagesMethods.reactions({
141
+ client: this.client,
142
+ channelId: this.id,
143
+ });
137
144
  static messages(ctx) {
138
145
  return {
139
146
  write: (body) => ctx.client.messages.write(ctx.channelId, body),
@@ -159,13 +166,22 @@ class MessagesMethods extends DiscordBase_1.DiscordBase {
159
166
  delete: (messageId, reason) => ctx.client.channels.deletePin(messageId, ctx.channelId, reason),
160
167
  };
161
168
  }
162
- static transformMessageBody(body) {
169
+ static transformMessageBody(body, files, self) {
163
170
  const poll = body.poll;
164
171
  return {
172
+ allowed_mentions: self.options?.allowedMentions,
165
173
  ...body,
166
174
  components: body.components?.map(x => (x instanceof builders_1.ActionRow ? x.toJSON() : x)) ?? undefined,
167
175
  embeds: body.embeds?.map(x => (x instanceof builders_1.Embed ? x.toJSON() : x)) ?? undefined,
168
- attachments: body.attachments?.map((x, i) => ({ id: i, ...(0, builders_1.resolveAttachment)(x) })) ?? undefined,
176
+ attachments: 'attachments' in body
177
+ ? body.attachments?.map((x, i) => ({
178
+ id: i,
179
+ ...(0, builders_1.resolveAttachment)(x),
180
+ })) ?? undefined
181
+ : files?.map((x, id) => ({
182
+ id,
183
+ filename: x.name,
184
+ })),
169
185
  poll: poll ? (poll instanceof builders_1.PollBuilder ? poll.toJSON() : poll) : undefined,
170
186
  };
171
187
  }
@@ -265,10 +281,22 @@ class VoiceChannelMethods extends DiscordBase_1.DiscordBase {
265
281
  const filter = states.filter(state => state.channelId === this.id);
266
282
  return filter;
267
283
  }
284
+ async members(force) {
285
+ const collection = new __1.Collection();
286
+ const states = await this.states();
287
+ for (const state of states) {
288
+ const member = await state.member(force);
289
+ collection.set(member.id, member);
290
+ }
291
+ return collection;
292
+ }
268
293
  }
269
294
  exports.VoiceChannelMethods = VoiceChannelMethods;
270
295
  class WebhookGuildMethods extends DiscordBase_1.DiscordBase {
271
- webhooks = WebhookGuildMethods.guild({ client: this.client, guildId: this.id });
296
+ webhooks = WebhookGuildMethods.guild({
297
+ client: this.client,
298
+ guildId: this.id,
299
+ });
272
300
  static guild(ctx) {
273
301
  return {
274
302
  list: () => ctx.client.webhooks.listFromGuild(ctx.guildId),
@@ -277,7 +305,10 @@ class WebhookGuildMethods extends DiscordBase_1.DiscordBase {
277
305
  }
278
306
  exports.WebhookGuildMethods = WebhookGuildMethods;
279
307
  class WebhookChannelMethods extends DiscordBase_1.DiscordBase {
280
- webhooks = WebhookChannelMethods.channel({ client: this.client, channelId: this.id });
308
+ webhooks = WebhookChannelMethods.channel({
309
+ client: this.client,
310
+ channelId: this.id,
311
+ });
281
312
  static channel(ctx) {
282
313
  return {
283
314
  list: () => ctx.client.webhooks.listFromChannel(ctx.channelId),
@@ -25,7 +25,7 @@ function resolvePartialEmoji(emoji) {
25
25
  if (emoji.includes('%')) {
26
26
  emoji = encodeURIComponent(emoji);
27
27
  }
28
- if (!emoji.includes(':') && !emoji.match(/\d{17,20}/g)) {
28
+ if (!(emoji.includes(':') || emoji.match(/\d{17,20}/g))) {
29
29
  return { name: emoji, id: null };
30
30
  }
31
31
  return;
@@ -8,5 +8,6 @@ export declare class BaseSocket {
8
8
  set onerror(callback: NodeWebSocket['onerror']);
9
9
  send(data: string): void;
10
10
  close(...args: Parameters<NodeWebSocket['close']>): void;
11
+ ping(): Promise<number>;
11
12
  get readyState(): number;
12
13
  }
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.BaseSocket = void 0;
7
+ const node_crypto_1 = require("node:crypto");
7
8
  const ws_1 = __importDefault(require("ws"));
8
9
  class BaseSocket {
9
10
  internal;
@@ -29,6 +30,22 @@ class BaseSocket {
29
30
  // @ts-expect-error
30
31
  return this.internal.close(...args);
31
32
  }
33
+ async ping() {
34
+ if (!('ping' in this.internal))
35
+ throw new Error('Unexpected: Method ping not implemented');
36
+ return new Promise(res => {
37
+ const nonce = (0, node_crypto_1.randomUUID)();
38
+ const start = performance.now();
39
+ const listener = (data) => {
40
+ if (data.toString() !== nonce)
41
+ return;
42
+ this.internal.removeListener('pong', listener);
43
+ res(performance.now() - start);
44
+ };
45
+ this.internal.on('pong', listener);
46
+ this.internal.ping(nonce);
47
+ });
48
+ }
32
49
  get readyState() {
33
50
  return this.internal.readyState;
34
51
  }
@@ -30,6 +30,7 @@ export declare class Shard {
30
30
  get gatewayURL(): string;
31
31
  get resumeGatewayURL(): string | undefined;
32
32
  get currentGatewayURL(): string;
33
+ ping(): Promise<number>;
33
34
  connect(): Promise<void>;
34
35
  send<T extends GatewaySendPayload = GatewaySendPayload>(force: boolean, message: T): Promise<void>;
35
36
  identify(): Promise<void>;
@@ -55,6 +55,11 @@ class Shard {
55
55
  url.searchParams.set('v', '10');
56
56
  return url.href;
57
57
  }
58
+ ping() {
59
+ if (!this.websocket)
60
+ return Promise.resolve(Number.POSITIVE_INFINITY);
61
+ return this.websocket.ping();
62
+ }
58
63
  async connect() {
59
64
  await this.connectTimeout.wait();
60
65
  if (this.isOpen) {
@@ -63,6 +68,7 @@ class Shard {
63
68
  }
64
69
  this.debugger?.debug(`[Shard #${this.id}] Connecting to ${this.currentGatewayURL}`);
65
70
  // @ts-expect-error @types/bun cause erros in compile
71
+ // biome-ignore lint/correctness/noUndeclaredVariables: /\ bun lol
66
72
  this.websocket = new basesocket_1.BaseSocket(typeof Bun === 'undefined' ? 'ws' : 'bun', this.currentGatewayURL);
67
73
  this.websocket.onmessage = (event) => this.handleMessage(event);
68
74
  this.websocket.onclose = (event) => this.handleClosed(event);
@@ -2,12 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ShardManager = void 0;
4
4
  const v10_1 = require("discord-api-types/v10");
5
- const node_worker_threads_1 = require("node:worker_threads");
6
5
  const common_1 = require("../../common");
7
6
  const constants_1 = require("../constants");
8
7
  const structures_1 = require("../structures");
9
8
  const timeout_1 = require("../structures/timeout");
10
9
  const shard_js_1 = require("./shard.js");
10
+ let parentPort;
11
+ let workerData;
11
12
  class ShardManager extends Map {
12
13
  connectQueue;
13
14
  options;
@@ -23,6 +24,12 @@ class ShardManager extends Map {
23
24
  logLevel: common_1.LogLevels.Debug,
24
25
  });
25
26
  }
27
+ const worker_threads = (0, common_1.lazyLoadPackage)('node:worker_threads');
28
+ if (worker_threads) {
29
+ workerData = worker_threads.workerData;
30
+ if (worker_threads.parentPort)
31
+ parentPort = worker_threads.parentPort;
32
+ }
26
33
  }
27
34
  get totalShards() {
28
35
  return this.options.totalShards ?? this.options.info.shards;
@@ -148,8 +155,8 @@ class ShardManager extends Map {
148
155
  });
149
156
  }
150
157
  send(shardId, payload) {
151
- if (node_worker_threads_1.workerData?.__USING_WATCHER__) {
152
- return node_worker_threads_1.parentPort?.postMessage({
158
+ if (workerData?.__USING_WATCHER__) {
159
+ return parentPort?.postMessage({
153
160
  type: 'SEND_TO_SHARD',
154
161
  shardId,
155
162
  payload,
@@ -100,4 +100,5 @@ export interface WorkerData {
100
100
  workerId: number;
101
101
  debug: boolean;
102
102
  workerProxy: boolean;
103
+ __USING_WATCHER__?: boolean;
103
104
  }
@@ -7,7 +7,6 @@
7
7
  /// <reference types="node" />
8
8
  import type { GatewayPresenceUpdateData, GatewaySendPayload } from 'discord-api-types/v10';
9
9
  import { type Worker as ClusterWorker } from 'node:cluster';
10
- import { Worker as ThreadWorker } from 'node:worker_threads';
11
10
  import { ApiHandler, Logger } from '../..';
12
11
  import { type Adapter } from '../../cache';
13
12
  import { type MakePartial } from '../../common';
@@ -16,7 +15,7 @@ import { MemberUpdateHandler } from './events/memberUpdate';
16
15
  import { PresenceUpdateHandler } from './events/presenceUpdate';
17
16
  import type { ShardOptions, WorkerData, WorkerManagerOptions } from './shared';
18
17
  import type { WorkerInfo, WorkerMessage, WorkerShardInfo } from './worker';
19
- export declare class WorkerManager extends Map<number, (ClusterWorker | ThreadWorker) & {
18
+ export declare class WorkerManager extends Map<number, (ClusterWorker | import('node:worker_threads').Worker) & {
20
19
  ready?: boolean;
21
20
  }> {
22
21
  options: Required<WorkerManagerOptions>;
@@ -50,7 +49,7 @@ export declare class WorkerManager extends Map<number, (ClusterWorker | ThreadWo
50
49
  prepareSpaces(): number[][];
51
50
  postMessage(id: number, body: any): void;
52
51
  prepareWorkers(shards: number[][]): Promise<void>;
53
- createWorker(workerData: WorkerData): ClusterWorker | ThreadWorker;
52
+ createWorker(workerData: WorkerData): ClusterWorker | import("worker_threads").Worker;
54
53
  spawn(workerId: number, shardId: number): void;
55
54
  handleWorkerMessage(message: WorkerMessage): Promise<void>;
56
55
  private generateNonce;
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.WorkerManager = void 0;
7
7
  const node_cluster_1 = __importDefault(require("node:cluster"));
8
8
  const node_crypto_1 = require("node:crypto");
9
- const node_worker_threads_1 = require("node:worker_threads");
10
9
  const __1 = require("../..");
11
10
  const cache_1 = require("../../cache");
12
11
  const base_1 = require("../../client/base");
@@ -139,6 +138,9 @@ class WorkerManager extends Map {
139
138
  }
140
139
  }
141
140
  createWorker(workerData) {
141
+ const worker_threads = (0, common_1.lazyLoadPackage)('node:worker_threads');
142
+ if (!worker_threads)
143
+ throw new Error('Cannot create worker without worker_threads.');
142
144
  const env = {
143
145
  SEYFERT_SPAWNING: 'true',
144
146
  };
@@ -147,7 +149,7 @@ class WorkerManager extends Map {
147
149
  }
148
150
  switch (this.options.mode) {
149
151
  case 'threads': {
150
- const worker = new node_worker_threads_1.Worker(workerData.path, {
152
+ const worker = new worker_threads.Worker(workerData.path, {
151
153
  env,
152
154
  });
153
155
  worker.on('message', data => this.handleWorkerMessage(data));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seyfert",
3
- "version": "1.3.3",
3
+ "version": "1.5.0",
4
4
  "description": "The most advanced framework for discord bots",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",
@@ -21,10 +21,10 @@
21
21
  "license": "Apache-2.0",
22
22
  "dependencies": {
23
23
  "chokidar": "^3.6.0",
24
- "discord-api-types": "^0.37.81",
24
+ "discord-api-types": "^0.37.86",
25
25
  "magic-bytes.js": "^1.10.0",
26
26
  "ts-mixer": "^6.0.4",
27
- "ws": "^8.16.0"
27
+ "ws": "^8.17.0"
28
28
  },
29
29
  "lint-staged": {
30
30
  "*.ts": [
@@ -33,13 +33,13 @@
33
33
  ]
34
34
  },
35
35
  "devDependencies": {
36
- "@biomejs/biome": "1.6.0",
37
- "@commitlint/cli": "^19.2.2",
36
+ "@biomejs/biome": "1.7.3",
37
+ "@commitlint/cli": "^19.3.0",
38
38
  "@commitlint/config-conventional": "^19.2.2",
39
- "@types/node": "^20.12.7",
39
+ "@types/node": "^20.12.12",
40
40
  "@types/ws": "^8.5.10",
41
41
  "husky": "^9.0.11",
42
- "lint-staged": "^15.2.2",
42
+ "lint-staged": "^15.2.5",
43
43
  "typescript": "^5.4.5"
44
44
  },
45
45
  "optionalDependencies": {
@@ -1,15 +0,0 @@
1
- import type { ComponentCommandInteractionMap, ComponentContext } from '../components/componentcontext';
2
- import type { MessageCommandInteraction, UserCommandInteraction } from '../structures';
3
- import type { CommandContext } from './applications/chatcontext';
4
- import type { MenuCommandContext } from './applications/menucontext';
5
- import type { UsingClient } from './applications/shared';
6
- export declare class BaseContext {
7
- readonly client: UsingClient;
8
- constructor(client: UsingClient);
9
- get proxy(): import("..").APIRoutes;
10
- isChat(): this is CommandContext;
11
- isMenu(): this is MenuCommandContext<UserCommandInteraction | MessageCommandInteraction>;
12
- isMenuUser(): this is MenuCommandContext<UserCommandInteraction>;
13
- isMenuMessage(): this is MenuCommandContext<MessageCommandInteraction>;
14
- isComponent(): this is ComponentContext<keyof ComponentCommandInteractionMap>;
15
- }