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.
- package/lib/api/CDN.d.ts +1 -1
- package/lib/api/CDN.js +0 -2
- package/lib/api/Router.js +2 -2
- package/lib/api/Routes/applications.d.ts +29 -33
- package/lib/api/Routes/channels.d.ts +11 -17
- package/lib/api/Routes/interactions.d.ts +3 -7
- package/lib/api/Routes/webhooks.d.ts +4 -6
- package/lib/builders/Attachment.d.ts +2 -3
- package/lib/cache/adapters/redis.js +6 -0
- package/lib/cache/adapters/workeradapter.d.ts +4 -4
- package/lib/cache/adapters/workeradapter.js +10 -5
- package/lib/cache/index.d.ts +4 -5
- package/lib/cache/index.js +4 -3
- package/lib/cache/resources/default/base.d.ts +2 -1
- package/lib/cache/resources/default/guild-based.d.ts +2 -1
- package/lib/cache/resources/default/guild-based.js +6 -6
- package/lib/cache/resources/default/guild-related.d.ts +2 -1
- package/lib/cache/resources/default/guild-related.js +1 -1
- package/lib/cache/resources/guilds.js +2 -1
- package/lib/cache/resources/overwrites.d.ts +1 -1
- package/lib/cache/resources/overwrites.js +7 -1
- package/lib/client/base.d.ts +18 -170
- package/lib/client/base.js +11 -14
- package/lib/client/client.d.ts +5 -0
- package/lib/client/client.js +4 -1
- package/lib/client/oninteractioncreate.js +2 -2
- package/lib/client/onmessagecreate.js +188 -152
- package/lib/client/workerclient.d.ts +1 -0
- package/lib/client/workerclient.js +36 -15
- package/lib/collection.js +2 -2
- package/lib/commands/applications/chat.d.ts +15 -7
- package/lib/commands/applications/chat.js +7 -7
- package/lib/commands/applications/chatcontext.d.ts +5 -3
- package/lib/commands/applications/chatcontext.js +6 -1
- package/lib/commands/applications/menu.d.ts +5 -1
- package/lib/commands/applications/menu.js +4 -0
- package/lib/commands/applications/menucontext.d.ts +4 -2
- package/lib/commands/applications/menucontext.js +6 -1
- package/lib/commands/applications/options.d.ts +1 -2
- package/lib/commands/decorators.d.ts +17 -5
- package/lib/commands/decorators.js +17 -7
- package/lib/commands/handler.d.ts +5 -5
- package/lib/commands/handler.js +40 -36
- package/lib/commands/optionresolver.d.ts +11 -4
- package/lib/commands/optionresolver.js +6 -4
- package/lib/common/index.d.ts +7 -0
- package/lib/common/index.js +7 -0
- package/lib/common/it/utils.js +2 -0
- package/lib/common/shorters/channels.d.ts +67 -129
- package/lib/common/shorters/channels.js +119 -135
- package/lib/common/shorters/emojis.d.ts +47 -0
- package/lib/common/shorters/emojis.js +80 -0
- package/lib/common/shorters/guilds.d.ts +22 -249
- package/lib/common/shorters/guilds.js +51 -140
- package/lib/common/shorters/members.d.ts +82 -108
- package/lib/common/shorters/members.js +151 -166
- package/lib/common/shorters/messages.d.ts +11 -23
- package/lib/common/shorters/messages.js +58 -104
- package/lib/common/shorters/reactions.d.ts +10 -0
- package/lib/common/shorters/reactions.js +45 -0
- package/lib/common/shorters/roles.d.ts +39 -7
- package/lib/common/shorters/roles.js +74 -42
- package/lib/common/shorters/templates.d.ts +6 -8
- package/lib/common/shorters/templates.js +17 -21
- package/lib/common/shorters/users.d.ts +4 -0
- package/lib/common/shorters/users.js +30 -0
- package/lib/common/shorters/webhook.d.ts +62 -26
- package/lib/common/shorters/webhook.js +113 -58
- package/lib/common/types/options.d.ts +2 -2
- package/lib/components/handler.d.ts +10 -7
- package/lib/components/handler.js +20 -5
- package/lib/index.d.ts +4 -2
- package/lib/langs/handler.js +7 -2
- package/lib/structures/AutoModerationRule.d.ts +2 -2
- package/lib/structures/ClientUser.d.ts +2 -2
- package/lib/structures/Guild.d.ts +2 -2
- package/lib/structures/GuildEmoji.d.ts +4 -4
- package/lib/structures/GuildEmoji.js +7 -7
- package/lib/structures/GuildMember.d.ts +6 -6
- package/lib/structures/GuildMember.js +2 -2
- package/lib/structures/GuildPreview.d.ts +2 -2
- package/lib/structures/GuildRole.d.ts +2 -2
- package/lib/structures/GuildTemplate.d.ts +2 -2
- package/lib/structures/Interaction.d.ts +7 -8
- package/lib/structures/Interaction.js +1 -1
- package/lib/structures/Message.d.ts +7 -6
- package/lib/structures/Message.js +7 -4
- package/lib/structures/Sticker.d.ts +2 -2
- package/lib/structures/Webhook.d.ts +2 -2
- package/lib/structures/Webhook.js +3 -3
- package/lib/structures/channels.d.ts +19 -20
- package/lib/structures/channels.js +13 -25
- package/lib/structures/extra/Base.d.ts +1 -2
- package/lib/structures/extra/DiscordBase.d.ts +2 -2
- package/lib/websocket/constants/index.js +1 -0
- package/lib/websocket/discord/shard.js +4 -2
- package/lib/websocket/discord/sharder.d.ts +3 -0
- package/lib/websocket/discord/sharder.js +12 -5
- package/lib/websocket/discord/shared.d.ts +1 -0
- package/lib/websocket/discord/worker.d.ts +2 -1
- package/lib/websocket/discord/workermanager.d.ts +8 -3
- package/lib/websocket/discord/workermanager.js +78 -30
- package/package.json +8 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ListenerOptions } from '../builders';
|
|
2
|
-
import type {
|
|
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:
|
|
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<
|
|
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:
|
|
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:
|
|
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.
|
|
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.
|
|
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.
|
|
123
|
+
return this.client.webhooks.writeMessage(this.webhookId, this.webhookToken, body);
|
|
121
124
|
}
|
|
122
125
|
delete(reason) {
|
|
123
|
-
return this.client.webhooks.
|
|
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:
|
|
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 {
|
|
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:
|
|
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.
|
|
51
|
-
edit: (payload) => client.webhooks.
|
|
52
|
-
delete: (messageId, reason) => client.webhooks.
|
|
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 {
|
|
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:
|
|
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:
|
|
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<
|
|
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<
|
|
123
|
-
delete: (messageId: string, emoji: EmojiResolvable, userId?: string) => Promise<
|
|
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<
|
|
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<
|
|
141
|
-
delete: (messageId: string, emoji: EmojiResolvable, userId?: string) => Promise<
|
|
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<
|
|
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:
|
|
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.
|
|
105
|
+
return this.client.channels.memberPermissions(this.id, member, checkAdmin);
|
|
107
106
|
}
|
|
108
107
|
rolePermissions(role, checkAdmin = true) {
|
|
109
|
-
return this.client.channels.
|
|
108
|
+
return this.client.channels.rolePermissions(this.id, role, checkAdmin);
|
|
110
109
|
}
|
|
111
110
|
overwritesFor(member) {
|
|
112
|
-
return this.client.channels.
|
|
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.
|
|
151
|
-
delete: (messageId, emoji, userId = '@me') => ctx.client.
|
|
152
|
-
fetch: (messageId, emoji, query) => ctx.client.
|
|
153
|
-
purge: (messageId, emoji) => ctx.client.
|
|
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
|
|
159
|
-
set: (messageId, reason) => ctx.client.channels.
|
|
160
|
-
delete: (messageId, reason) => ctx.client.channels.
|
|
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:
|
|
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:
|
|
270
|
-
|
|
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,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
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:
|
|
7
|
+
constructor(client: UsingClient,
|
|
8
8
|
/** Unique ID of the object */
|
|
9
9
|
data: Data);
|
|
10
10
|
/**
|
|
@@ -42,7 +42,9 @@ class Shard {
|
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
get latency() {
|
|
45
|
-
return this.heart.lastAck && this.heart.lastBeat
|
|
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:
|
|
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.
|
|
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) +
|
|
87
|
+
const id = i + (index > 0 ? index * this.concurrency : 0) + this.shardStart;
|
|
81
88
|
chunks[index][i] = this.spawn(id);
|
|
82
89
|
}
|
|
83
90
|
});
|
|
@@ -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
|
-
|
|
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,
|
|
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):
|
|
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;
|