seyfert 0.1.0 → 1.0.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/README.md +19 -30
- package/lib/api/CDN.d.ts +0 -8
- package/lib/api/CDN.js +7 -13
- package/lib/api/Router.d.ts +2 -2
- package/lib/api/Router.js +1 -1
- package/lib/api/Routes/applications.d.ts +1 -1
- package/lib/api/Routes/channels.d.ts +1 -1
- package/lib/api/Routes/gateway.d.ts +1 -1
- package/lib/api/Routes/guilds.d.ts +1 -1
- package/lib/api/Routes/interactions.d.ts +1 -1
- package/lib/api/Routes/invites.d.ts +1 -1
- package/lib/api/Routes/stage-instances.d.ts +1 -1
- package/lib/api/Routes/stickers.d.ts +1 -1
- package/lib/api/Routes/users.d.ts +1 -1
- package/lib/api/Routes/voice.d.ts +1 -1
- package/lib/api/Routes/webhooks.d.ts +1 -1
- package/lib/api/api.d.ts +39 -0
- package/lib/api/api.js +318 -0
- package/lib/api/bucket.d.ts +19 -0
- package/lib/api/bucket.js +71 -0
- package/lib/api/index.d.ts +1 -1
- package/lib/api/index.js +1 -1
- package/lib/api/shared.d.ts +31 -5
- package/lib/api/shared.js +2 -7
- package/lib/api/utils/constants.d.ts +1 -30
- package/lib/api/utils/constants.js +2 -41
- package/lib/api/utils/types.d.ts +1 -320
- package/lib/api/utils/utils.d.ts +0 -38
- package/lib/api/utils/utils.js +1 -139
- package/lib/builders/ActionRow.js +1 -1
- package/lib/builders/Attachment.d.ts +14 -6
- package/lib/builders/Attachment.js +30 -7
- package/lib/builders/Button.d.ts +3 -12
- package/lib/builders/Button.js +0 -11
- package/lib/builders/{MessageEmbed.d.ts → Embed.d.ts} +15 -15
- package/lib/builders/{MessageEmbed.js → Embed.js} +16 -16
- package/lib/builders/Modal.js +1 -1
- package/lib/builders/SelectMenu.d.ts +14 -15
- package/lib/builders/SelectMenu.js +19 -18
- package/lib/builders/index.d.ts +1 -1
- package/lib/builders/index.js +1 -1
- package/lib/builders/types.d.ts +2 -2
- package/lib/cache/adapters/default.js +2 -2
- package/lib/cache/adapters/redis.d.ts +2 -3
- package/lib/cache/adapters/redis.js +13 -5
- package/lib/cache/adapters/workeradapter.d.ts +9 -1
- package/lib/cache/adapters/workeradapter.js +7 -3
- package/lib/cache/index.d.ts +20 -6
- package/lib/cache/index.js +26 -10
- package/lib/cache/resources/channels.d.ts +6 -2
- package/lib/cache/resources/channels.js +12 -6
- package/lib/cache/resources/default/base.d.ts +17 -16
- package/lib/cache/resources/default/base.js +25 -24
- package/lib/cache/resources/default/guild-based.d.ts +22 -19
- package/lib/cache/resources/default/guild-based.js +32 -31
- package/lib/cache/resources/default/guild-related.d.ts +22 -19
- package/lib/cache/resources/default/guild-related.js +37 -43
- package/lib/cache/resources/emojis.d.ts +4 -2
- package/lib/cache/resources/emojis.js +8 -6
- package/lib/cache/resources/guilds.d.ts +4 -2
- package/lib/cache/resources/guilds.js +15 -8
- package/lib/cache/resources/members.d.ts +4 -2
- package/lib/cache/resources/members.js +16 -13
- package/lib/cache/resources/overwrites.d.ts +25 -0
- package/lib/cache/resources/overwrites.js +39 -0
- package/lib/cache/resources/presence.js +3 -4
- package/lib/cache/resources/roles.d.ts +4 -2
- package/lib/cache/resources/roles.js +8 -6
- package/lib/cache/resources/stickers.d.ts +4 -2
- package/lib/cache/resources/stickers.js +8 -6
- package/lib/cache/resources/threads.d.ts +4 -2
- package/lib/cache/resources/threads.js +8 -6
- package/lib/cache/resources/users.d.ts +4 -2
- package/lib/cache/resources/users.js +8 -6
- package/lib/cache/resources/voice-states.d.ts +3 -3
- package/lib/cache/resources/voice-states.js +6 -7
- package/lib/client/base.d.ts +49 -16
- package/lib/client/base.js +21 -17
- package/lib/client/client.d.ts +14 -3
- package/lib/client/client.js +21 -21
- package/lib/client/httpclient.d.ts +3 -5
- package/lib/client/httpclient.js +29 -16
- package/lib/client/{oninteraction.d.ts → oninteractioncreate.d.ts} +1 -1
- package/lib/client/{oninteraction.js → oninteractioncreate.js} +34 -23
- package/lib/client/onmessagecreate.d.ts +3 -0
- package/lib/client/onmessagecreate.js +337 -0
- package/lib/client/workerclient.d.ts +5 -1
- package/lib/client/workerclient.js +67 -44
- package/lib/collection.d.ts +1 -1
- package/lib/collection.js +9 -6
- package/lib/commands/applications/chat.d.ts +32 -25
- package/lib/commands/applications/chat.js +51 -34
- package/lib/commands/applications/chatcontext.d.ts +34 -16
- package/lib/commands/applications/chatcontext.js +99 -20
- package/lib/commands/applications/menu.d.ts +9 -8
- package/lib/commands/applications/menu.js +14 -5
- package/lib/commands/applications/menucontext.d.ts +27 -10
- package/lib/commands/applications/menucontext.js +51 -7
- package/lib/commands/applications/options.d.ts +13 -13
- package/lib/commands/applications/shared.d.ts +7 -2
- package/lib/commands/decorators.d.ts +14 -14
- package/lib/commands/decorators.js +9 -5
- package/lib/commands/handler.d.ts +2 -1
- package/lib/commands/handler.js +60 -14
- package/lib/commands/index.d.ts +1 -1
- package/lib/commands/index.js +2 -1
- package/lib/commands/optionresolver.d.ts +6 -5
- package/lib/commands/optionresolver.js +10 -6
- package/lib/common/bot/watcher.d.ts +3 -3
- package/lib/common/bot/watcher.js +3 -1
- package/lib/common/index.d.ts +1 -1
- package/lib/common/index.js +2 -1
- package/lib/common/it/logger.d.ts +11 -0
- package/lib/common/it/logger.js +51 -2
- package/lib/common/it/utils.d.ts +3 -13
- package/lib/common/it/utils.js +9 -30
- package/lib/common/shorters/channels.d.ts +55 -5
- package/lib/common/shorters/channels.js +59 -0
- package/lib/common/shorters/guilds.d.ts +5 -2
- package/lib/common/shorters/guilds.js +18 -0
- package/lib/common/shorters/messages.js +0 -2
- package/lib/common/shorters/overwrites.d.ts +29 -0
- package/lib/common/shorters/overwrites.js +63 -0
- package/lib/common/shorters/roles.js +3 -3
- package/lib/common/shorters/webhook.d.ts +2 -2
- package/lib/common/types/util.d.ts +2 -1
- package/lib/common/types/write.d.ts +3 -7
- package/lib/components/handler.d.ts +12 -18
- package/lib/components/handler.js +58 -103
- package/lib/components/index.d.ts +0 -1
- package/lib/components/index.js +0 -1
- package/lib/components/listener.d.ts +2 -2
- package/lib/components/listener.js +2 -3
- package/lib/events/event.d.ts +2 -2
- package/lib/events/handler.d.ts +3 -2
- package/lib/events/handler.js +14 -6
- package/lib/events/hooks/dispatch.d.ts +2 -1
- package/lib/events/hooks/dispatch.js +5 -1
- package/lib/events/hooks/thread.d.ts +63 -63
- package/lib/index.d.ts +8 -5
- package/lib/index.js +20 -10
- package/lib/langs/handler.d.ts +6 -4
- package/lib/langs/handler.js +10 -8
- package/lib/langs/router.d.ts +8 -9
- package/lib/langs/router.js +5 -5
- package/lib/structures/ClientUser.d.ts +1 -16
- package/lib/structures/ClientUser.js +0 -31
- package/lib/structures/Guild.d.ts +1 -1
- package/lib/structures/GuildMember.d.ts +12 -0
- package/lib/structures/GuildMember.js +14 -0
- package/lib/structures/GuildRole.d.ts +4 -2
- package/lib/structures/GuildRole.js +4 -1
- package/lib/structures/GuildTemplate.js +1 -1
- package/lib/structures/Interaction.d.ts +2 -0
- package/lib/structures/Interaction.js +12 -13
- package/lib/structures/Message.d.ts +7 -2
- package/lib/structures/Message.js +6 -3
- package/lib/structures/Sticker.d.ts +1 -1
- package/lib/structures/Sticker.js +1 -1
- package/lib/structures/User.d.ts +5 -0
- package/lib/structures/User.js +3 -0
- package/lib/structures/Webhook.d.ts +1 -1
- package/lib/structures/Webhook.js +1 -1
- package/lib/structures/channels.d.ts +45 -6
- package/lib/structures/channels.js +23 -7
- package/lib/structures/extra/BitField.d.ts +9 -6
- package/lib/structures/extra/BitField.js +27 -3
- package/lib/structures/extra/Permissions.d.ts +6 -1
- package/lib/structures/extra/Permissions.js +7 -0
- package/lib/websocket/discord/basesocket.js +0 -1
- package/lib/websocket/discord/workermanager.d.ts +9 -1
- package/lib/websocket/discord/workermanager.js +21 -13
- package/package.json +21 -20
- package/lib/api/REST.d.ts +0 -127
- package/lib/api/REST.js +0 -424
- package/lib/api/errors/DiscordAPIError.d.ts +0 -51
- package/lib/api/errors/DiscordAPIError.js +0 -81
- package/lib/api/errors/HTTPError.d.ts +0 -20
- package/lib/api/errors/HTTPError.js +0 -28
- package/lib/api/errors/RateLimitError.d.ts +0 -19
- package/lib/api/errors/RateLimitError.js +0 -37
- package/lib/api/handlers/BurstHandler.d.ts +0 -51
- package/lib/api/handlers/BurstHandler.js +0 -124
- package/lib/api/handlers/SequentialHandler.d.ts +0 -81
- package/lib/api/handlers/SequentialHandler.js +0 -365
- package/lib/api/handlers/Shared.d.ts +0 -14
- package/lib/api/handlers/Shared.js +0 -125
- package/lib/api/interfaces/Handler.d.ts +0 -21
- package/lib/api/interfaces/Handler.js +0 -2
- package/lib/websocket/discord/handlemessage.d.ts +0 -0
- package/lib/websocket/discord/handlemessage.js +0 -1
- package/lib/websocket/discord/memberUpdate.d.ts +0 -16
- package/lib/websocket/discord/memberUpdate.js +0 -47
|
@@ -1,6 +1,8 @@
|
|
|
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
2
|
import type { BaseClient } from '../client/base';
|
|
3
3
|
import type { APIChannelBase, APIGuildChannel, APIGuildForumDefaultReactionEmoji, APIGuildForumTag, EmojiResolvable, MessageCreateBodyRequest, MessageUpdateBodyRequest, MethodContext, ObjectToLower, RESTGetAPIChannelMessageReactionUsersQuery, RESTPatchAPIChannelJSONBody, RESTPatchAPIGuildChannelPositionsJSONBody, RESTPostAPIChannelWebhookJSONBody, RESTPostAPIGuildChannelJSONBody, SortOrderType, StringToNumber, ToClass } from '../common';
|
|
4
|
+
import type { GuildMember } from './GuildMember';
|
|
5
|
+
import type { GuildRole } from './GuildRole';
|
|
4
6
|
import { Webhook } from './Webhook';
|
|
5
7
|
import { DiscordBase } from './extra/DiscordBase';
|
|
6
8
|
export declare class BaseChannel<T extends ChannelType> extends DiscordBase<APIChannelBase<ChannelType>> {
|
|
@@ -53,9 +55,46 @@ interface IChannelTypes {
|
|
|
53
55
|
GuildCategory: CategoryChannel;
|
|
54
56
|
GuildAnnouncement: NewsChannel;
|
|
55
57
|
}
|
|
56
|
-
export interface BaseGuildChannel extends ObjectToLower<APIGuildChannel<ChannelType>> {
|
|
58
|
+
export interface BaseGuildChannel extends ObjectToLower<Omit<APIGuildChannel<ChannelType>, 'permission_overwrites'>> {
|
|
57
59
|
}
|
|
58
60
|
export declare class BaseGuildChannel extends BaseChannel<ChannelType> {
|
|
61
|
+
constructor(client: BaseClient, data: APIGuildChannel<ChannelType>);
|
|
62
|
+
permissionOverwrites: {
|
|
63
|
+
fetch: () => import("..").ReturnCache<{
|
|
64
|
+
type: number;
|
|
65
|
+
id: string;
|
|
66
|
+
deny: import("./extra/Permissions").PermissionsBitField;
|
|
67
|
+
allow: import("./extra/Permissions").PermissionsBitField;
|
|
68
|
+
}[] | undefined>;
|
|
69
|
+
values: () => {
|
|
70
|
+
type: number;
|
|
71
|
+
id: string;
|
|
72
|
+
deny: import("./extra/Permissions").PermissionsBitField;
|
|
73
|
+
allow: import("./extra/Permissions").PermissionsBitField;
|
|
74
|
+
}[][];
|
|
75
|
+
};
|
|
76
|
+
memberPermissions(member: GuildMember, checkAdmin?: boolean): Promise<import("./extra/Permissions").PermissionsBitField>;
|
|
77
|
+
rolePermissions(role: GuildRole, checkAdmin?: boolean): Promise<import("./extra/Permissions").PermissionsBitField>;
|
|
78
|
+
overwritesFor(member: GuildMember): Promise<{
|
|
79
|
+
everyone: {
|
|
80
|
+
type: number;
|
|
81
|
+
id: string;
|
|
82
|
+
deny: import("./extra/Permissions").PermissionsBitField;
|
|
83
|
+
allow: import("./extra/Permissions").PermissionsBitField;
|
|
84
|
+
} | undefined;
|
|
85
|
+
roles: {
|
|
86
|
+
type: number;
|
|
87
|
+
id: string;
|
|
88
|
+
deny: import("./extra/Permissions").PermissionsBitField;
|
|
89
|
+
allow: import("./extra/Permissions").PermissionsBitField;
|
|
90
|
+
}[];
|
|
91
|
+
member: {
|
|
92
|
+
type: number;
|
|
93
|
+
id: string;
|
|
94
|
+
deny: import("./extra/Permissions").PermissionsBitField;
|
|
95
|
+
allow: import("./extra/Permissions").PermissionsBitField;
|
|
96
|
+
} | undefined;
|
|
97
|
+
}>;
|
|
59
98
|
guild(force?: boolean): Promise<import("./Guild").Guild<"cached"> | import("./Guild").Guild<"api">>;
|
|
60
99
|
get url(): string;
|
|
61
100
|
setPosition(position: number, reason?: string): Promise<AllChannels>;
|
|
@@ -112,7 +151,7 @@ export declare class MessagesMethods extends DiscordBase {
|
|
|
112
151
|
};
|
|
113
152
|
static transformMessageBody<T>(body: MessageCreateBodyRequest | MessageUpdateBodyRequest): T;
|
|
114
153
|
}
|
|
115
|
-
export interface TextBaseGuildChannel extends ObjectToLower<Omit<APITextChannel, 'type'>>, MessagesMethods {
|
|
154
|
+
export interface TextBaseGuildChannel extends ObjectToLower<Omit<APITextChannel, 'type' | 'permission_overwrites'>>, MessagesMethods {
|
|
116
155
|
}
|
|
117
156
|
export declare class TextBaseGuildChannel extends BaseGuildChannel {
|
|
118
157
|
}
|
|
@@ -161,7 +200,7 @@ export declare class WebhookChannelMethods extends DiscordBase {
|
|
|
161
200
|
create: (body: RESTPostAPIChannelWebhookJSONBody) => Promise<Webhook>;
|
|
162
201
|
};
|
|
163
202
|
}
|
|
164
|
-
export interface TextGuildChannel extends ObjectToLower<Omit<APITextChannel, 'type'>>, BaseGuildChannel, TextBaseGuildChannel, WebhookChannelMethods {
|
|
203
|
+
export interface TextGuildChannel extends ObjectToLower<Omit<APITextChannel, 'type' | 'permission_overwrites'>>, BaseGuildChannel, TextBaseGuildChannel, WebhookChannelMethods {
|
|
165
204
|
}
|
|
166
205
|
export declare class TextGuildChannel extends BaseGuildChannel {
|
|
167
206
|
type: ChannelType.GuildText;
|
|
@@ -174,7 +213,7 @@ declare const DMChannel_base: ToClass<Omit<BaseChannel<ChannelType.DM>, "edit">,
|
|
|
174
213
|
export declare class DMChannel extends DMChannel_base {
|
|
175
214
|
type: ChannelType.DM;
|
|
176
215
|
}
|
|
177
|
-
export interface VoiceChannel extends ObjectToLower<APIGuildVoiceChannel
|
|
216
|
+
export interface VoiceChannel extends ObjectToLower<Omit<APIGuildVoiceChannel, 'permission_overwrites'>>, Omit<TextGuildChannel, 'type'>, VoiceChannelMethods, WebhookChannelMethods {
|
|
178
217
|
}
|
|
179
218
|
export declare class VoiceChannel extends BaseChannel<ChannelType.GuildVoice> {
|
|
180
219
|
type: ChannelType.GuildVoice;
|
|
@@ -194,7 +233,7 @@ export interface ForumChannel extends ObjectToLower<APIGuildForumChannel>, Omit<
|
|
|
194
233
|
export declare class ForumChannel extends BaseChannel<ChannelType.GuildForum> {
|
|
195
234
|
type: ChannelType.GuildForum;
|
|
196
235
|
}
|
|
197
|
-
export interface ThreadChannel extends ObjectToLower<APIThreadChannel
|
|
236
|
+
export interface ThreadChannel extends ObjectToLower<Omit<APIThreadChannel, 'permission_overwrites'>>, TextBaseGuildChannel {
|
|
198
237
|
}
|
|
199
238
|
export declare class ThreadChannel extends BaseChannel<ChannelType.PublicThread | ChannelType.AnnouncementThread | ChannelType.PrivateThread> {
|
|
200
239
|
type: ChannelType.PublicThread | ChannelType.AnnouncementThread | ChannelType.PrivateThread;
|
|
@@ -211,7 +250,7 @@ export declare class ThreadChannel extends BaseChannel<ChannelType.PublicThread
|
|
|
211
250
|
setInvitable(invitable?: boolean, reason?: string): Promise<AllChannels>;
|
|
212
251
|
setLocked(locked?: boolean, reason?: string): Promise<AllChannels>;
|
|
213
252
|
}
|
|
214
|
-
export interface CategoryChannel extends ObjectToLower<APIGuildCategoryChannel
|
|
253
|
+
export interface CategoryChannel extends ObjectToLower<Omit<APIGuildCategoryChannel, 'permission_overwrites'>> {
|
|
215
254
|
}
|
|
216
255
|
declare const CategoryChannel_base: ToClass<Omit<BaseGuildChannel, "type" | "setParent">, CategoryChannel>;
|
|
217
256
|
export declare class CategoryChannel extends CategoryChannel_base {
|
|
@@ -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 components_1 = require("../components");
|
|
14
13
|
const Webhook_1 = require("./Webhook");
|
|
15
14
|
const DiscordBase_1 = require("./extra/DiscordBase");
|
|
16
15
|
const functions_1 = require("./extra/functions");
|
|
@@ -32,7 +31,10 @@ class BaseChannel extends DiscordBase_1.DiscordBase {
|
|
|
32
31
|
return this.client.channels.delete(this.id, { reason });
|
|
33
32
|
}
|
|
34
33
|
edit(body, reason) {
|
|
35
|
-
return this.client.channels.edit(this.id, body, {
|
|
34
|
+
return this.client.channels.edit(this.id, body, {
|
|
35
|
+
reason,
|
|
36
|
+
guildId: 'guildId' in this ? this.guildId : '@me',
|
|
37
|
+
});
|
|
36
38
|
}
|
|
37
39
|
toString() {
|
|
38
40
|
return `<#${this.id}>`;
|
|
@@ -92,7 +94,24 @@ class BaseChannel extends DiscordBase_1.DiscordBase {
|
|
|
92
94
|
}
|
|
93
95
|
exports.BaseChannel = BaseChannel;
|
|
94
96
|
class BaseGuildChannel extends BaseChannel {
|
|
95
|
-
|
|
97
|
+
constructor(client, data) {
|
|
98
|
+
const { permission_overwrites, ...rest } = data;
|
|
99
|
+
super(client, rest);
|
|
100
|
+
}
|
|
101
|
+
permissionOverwrites = {
|
|
102
|
+
fetch: () => this.client.cache.overwrites?.get(this.id),
|
|
103
|
+
values: () => (this.guildId ? this.client.cache.overwrites?.values(this.guildId) ?? [] : []),
|
|
104
|
+
};
|
|
105
|
+
memberPermissions(member, checkAdmin = true) {
|
|
106
|
+
return this.client.channels.overwrites.memberPermissions(this.id, member, checkAdmin);
|
|
107
|
+
}
|
|
108
|
+
rolePermissions(role, checkAdmin = true) {
|
|
109
|
+
return this.client.channels.overwrites.rolePermissions(this.id, role, checkAdmin);
|
|
110
|
+
}
|
|
111
|
+
overwritesFor(member) {
|
|
112
|
+
return this.client.channels.overwrites.overwritesFor(this.id, member);
|
|
113
|
+
}
|
|
114
|
+
guild(force = false) {
|
|
96
115
|
return this.client.guilds.fetch(this.guildId, force);
|
|
97
116
|
}
|
|
98
117
|
get url() {
|
|
@@ -144,11 +163,8 @@ class MessagesMethods extends DiscordBase_1.DiscordBase {
|
|
|
144
163
|
static transformMessageBody(body) {
|
|
145
164
|
return {
|
|
146
165
|
...body,
|
|
147
|
-
components: body.components
|
|
148
|
-
? (body?.components instanceof components_1.ComponentsListener ? body.components.components : body.components).map(x => 'toJSON' in x ? x.toJSON() : x)
|
|
149
|
-
: undefined,
|
|
166
|
+
components: body.components?.map(x => ('toJSON' in x ? x.toJSON() : x)) ?? undefined,
|
|
150
167
|
embeds: body.embeds?.map(x => (x instanceof builders_1.Embed ? x.toJSON() : x)) ?? undefined,
|
|
151
|
-
//?
|
|
152
168
|
attachments: body.attachments?.map((x, i) => ({ id: i, ...(0, builders_1.resolveAttachment)(x) })) ?? undefined,
|
|
153
169
|
};
|
|
154
170
|
}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
export type BitFieldResolvable<T extends object> = keyof T | number | bigint | (keyof T | number | bigint)[];
|
|
2
2
|
export declare class BitField<T extends object> {
|
|
3
|
-
static None:
|
|
4
|
-
Flags:
|
|
3
|
+
static None: bigint;
|
|
4
|
+
Flags: Record<string, bigint>;
|
|
5
5
|
private bit;
|
|
6
6
|
constructor(bitfields?: BitFieldResolvable<T>);
|
|
7
7
|
set bits(bits: BitFieldResolvable<T>);
|
|
8
|
-
get bits():
|
|
9
|
-
add(...bits: BitFieldResolvable<T>[]):
|
|
10
|
-
remove(...bits: BitFieldResolvable<T>[]):
|
|
8
|
+
get bits(): bigint;
|
|
9
|
+
add(...bits: BitFieldResolvable<T>[]): bigint;
|
|
10
|
+
remove(...bits: BitFieldResolvable<T>[]): bigint;
|
|
11
11
|
has(...bits: BitFieldResolvable<T>[]): boolean;
|
|
12
|
+
missings(...bits: BitFieldResolvable<T>[]): bigint[];
|
|
12
13
|
equals(other: BitFieldResolvable<T>): boolean;
|
|
13
|
-
resolve(bits?: BitFieldResolvable<T>):
|
|
14
|
+
resolve(bits?: BitFieldResolvable<T>): bigint;
|
|
15
|
+
keys(...bits: BitFieldResolvable<T>[]): string[];
|
|
16
|
+
values(...bits: BitFieldResolvable<T>[]): bigint[];
|
|
14
17
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BitField = void 0;
|
|
4
4
|
class BitField {
|
|
5
|
-
static None =
|
|
5
|
+
static None = 0n;
|
|
6
6
|
Flags = {};
|
|
7
7
|
bit;
|
|
8
8
|
constructor(bitfields) {
|
|
@@ -32,17 +32,21 @@ class BitField {
|
|
|
32
32
|
const bitsResolved = bits.map(bit => this.resolve(bit));
|
|
33
33
|
return bitsResolved.every(bit => (this.bits & bit) === bit);
|
|
34
34
|
}
|
|
35
|
+
missings(...bits) {
|
|
36
|
+
const bitsResolved = bits.map(bit => this.resolve(bit));
|
|
37
|
+
return bitsResolved.filter(bit => (this.bits & bit) !== bit);
|
|
38
|
+
}
|
|
35
39
|
equals(other) {
|
|
36
40
|
return this.bits === this.resolve(other);
|
|
37
41
|
}
|
|
38
42
|
resolve(bits) {
|
|
39
43
|
switch (typeof bits) {
|
|
40
44
|
case 'number':
|
|
41
|
-
return bits;
|
|
45
|
+
return BigInt(bits);
|
|
42
46
|
case 'string':
|
|
43
47
|
return this.resolve(this.Flags[bits]);
|
|
44
48
|
case 'bigint':
|
|
45
|
-
return
|
|
49
|
+
return bits;
|
|
46
50
|
case 'object':
|
|
47
51
|
if (!Array.isArray(bits)) {
|
|
48
52
|
throw new TypeError(`Cannot resolve permission: ${bits}`);
|
|
@@ -52,5 +56,25 @@ class BitField {
|
|
|
52
56
|
throw new TypeError(`Cannot resolve permission: ${typeof bits === 'symbol' ? String(bits) : bits}`);
|
|
53
57
|
}
|
|
54
58
|
}
|
|
59
|
+
keys(...bits) {
|
|
60
|
+
const bitsResolved = bits.map(bit => BigInt(this.resolve(bit)));
|
|
61
|
+
return Object.entries(this.Flags).reduce((acc, value) => {
|
|
62
|
+
if (bitsResolved.some(bit => (bit & value[1]) === value[1])) {
|
|
63
|
+
acc.push(value[0]);
|
|
64
|
+
return acc;
|
|
65
|
+
}
|
|
66
|
+
return acc;
|
|
67
|
+
}, []);
|
|
68
|
+
}
|
|
69
|
+
values(...bits) {
|
|
70
|
+
const bitsResolved = bits.map(bit => BigInt(this.resolve(bit)));
|
|
71
|
+
return Object.entries(this.Flags).reduce((acc, value) => {
|
|
72
|
+
if (bitsResolved.some(bit => (bit & value[1]) === value[1])) {
|
|
73
|
+
acc.push(value[1]);
|
|
74
|
+
return acc;
|
|
75
|
+
}
|
|
76
|
+
return acc;
|
|
77
|
+
}, []);
|
|
78
|
+
}
|
|
55
79
|
}
|
|
56
80
|
exports.BitField = BitField;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PermissionFlagsBits } from 'discord-api-types/v10';
|
|
2
|
-
import {
|
|
2
|
+
import type { PermissionStrings } from '../../common';
|
|
3
|
+
import { BitField, type BitFieldResolvable } from './BitField';
|
|
3
4
|
export declare class PermissionsBitField extends BitField<typeof PermissionFlagsBits> {
|
|
4
5
|
Flags: {
|
|
5
6
|
readonly CreateInstantInvite: bigint;
|
|
@@ -51,4 +52,8 @@ export declare class PermissionsBitField extends BitField<typeof PermissionFlags
|
|
|
51
52
|
readonly UseExternalSounds: bigint;
|
|
52
53
|
readonly SendVoiceMessages: bigint;
|
|
53
54
|
};
|
|
55
|
+
static All: bigint;
|
|
56
|
+
keys: (...bits: BitFieldResolvable<typeof PermissionFlagsBits>[]) => PermissionStrings;
|
|
57
|
+
has(...bits: BitFieldResolvable<typeof PermissionFlagsBits>[]): boolean;
|
|
58
|
+
strictHas(...bits: BitFieldResolvable<typeof PermissionFlagsBits>[]): boolean;
|
|
54
59
|
}
|
|
@@ -5,5 +5,12 @@ const v10_1 = require("discord-api-types/v10");
|
|
|
5
5
|
const BitField_1 = require("./BitField");
|
|
6
6
|
class PermissionsBitField extends BitField_1.BitField {
|
|
7
7
|
Flags = v10_1.PermissionFlagsBits;
|
|
8
|
+
static All = Object.values(v10_1.PermissionFlagsBits).reduce((acc, value) => acc | value, 0n);
|
|
9
|
+
has(...bits) {
|
|
10
|
+
return super.has(...bits) || super.has('Administrator');
|
|
11
|
+
}
|
|
12
|
+
strictHas(...bits) {
|
|
13
|
+
return super.has(...bits);
|
|
14
|
+
}
|
|
8
15
|
}
|
|
9
16
|
exports.PermissionsBitField = PermissionsBitField;
|
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.BaseSocket = void 0;
|
|
7
7
|
const ws_1 = __importDefault(require("ws"));
|
|
8
|
-
// import UWebSocket from 'uWebSockets.js';
|
|
9
8
|
class BaseSocket {
|
|
10
9
|
internal;
|
|
11
10
|
constructor(kind, url) {
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
/// <reference types="node" />
|
|
5
|
+
/// <reference types="node" />
|
|
6
|
+
/// <reference types="node" />
|
|
2
7
|
import { Worker } from 'node:worker_threads';
|
|
3
8
|
import { type Adapter } from '../../cache';
|
|
4
9
|
import { Logger, type GatewayPresenceUpdateData, type GatewaySendPayload } from '../../common';
|
|
@@ -12,7 +17,10 @@ export declare class WorkerManager extends Map<number, Worker> {
|
|
|
12
17
|
debugger?: Logger;
|
|
13
18
|
connectQueue: ConnectQueue;
|
|
14
19
|
cacheAdapter: Adapter;
|
|
15
|
-
promises: Map<string,
|
|
20
|
+
promises: Map<string, {
|
|
21
|
+
resolve: (value: any) => void;
|
|
22
|
+
timeout: NodeJS.Timeout;
|
|
23
|
+
}>;
|
|
16
24
|
memberUpdateHandler: MemberUpdateHandler;
|
|
17
25
|
presenceUpdateHandler: PresenceUpdateHandler;
|
|
18
26
|
constructor(options: WorkerManagerOptions);
|
|
@@ -173,34 +173,37 @@ class WorkerManager extends Map {
|
|
|
173
173
|
break;
|
|
174
174
|
case 'RESULT_PAYLOAD':
|
|
175
175
|
{
|
|
176
|
-
const
|
|
177
|
-
if (!
|
|
176
|
+
const cacheData = this.promises.get(message.nonce);
|
|
177
|
+
if (!cacheData) {
|
|
178
178
|
return;
|
|
179
179
|
}
|
|
180
180
|
this.promises.delete(message.nonce);
|
|
181
|
-
|
|
181
|
+
clearTimeout(cacheData.timeout);
|
|
182
|
+
cacheData.resolve(true);
|
|
182
183
|
}
|
|
183
184
|
break;
|
|
184
185
|
case 'SHARD_INFO':
|
|
185
186
|
{
|
|
186
187
|
const { nonce, type, ...data } = message;
|
|
187
|
-
const
|
|
188
|
-
if (!
|
|
188
|
+
const cacheData = this.promises.get(nonce);
|
|
189
|
+
if (!cacheData) {
|
|
189
190
|
return;
|
|
190
191
|
}
|
|
191
192
|
this.promises.delete(nonce);
|
|
192
|
-
|
|
193
|
+
clearTimeout(cacheData.timeout);
|
|
194
|
+
cacheData.resolve(data);
|
|
193
195
|
}
|
|
194
196
|
break;
|
|
195
197
|
case 'WORKER_INFO':
|
|
196
198
|
{
|
|
197
199
|
const { nonce, type, ...data } = message;
|
|
198
|
-
const
|
|
199
|
-
if (!
|
|
200
|
+
const cacheData = this.promises.get(nonce);
|
|
201
|
+
if (!cacheData) {
|
|
200
202
|
return;
|
|
201
203
|
}
|
|
202
204
|
this.promises.delete(nonce);
|
|
203
|
-
|
|
205
|
+
clearTimeout(cacheData.timeout);
|
|
206
|
+
cacheData.resolve(data);
|
|
204
207
|
}
|
|
205
208
|
break;
|
|
206
209
|
case 'WORKER_READY':
|
|
@@ -215,20 +218,25 @@ class WorkerManager extends Map {
|
|
|
215
218
|
}
|
|
216
219
|
}
|
|
217
220
|
generateNonce(large = true) {
|
|
218
|
-
const
|
|
219
|
-
|
|
221
|
+
const uuid = (0, node_crypto_1.randomUUID)();
|
|
222
|
+
const nonce = large ? uuid : uuid.split('-')[0];
|
|
223
|
+
if (this.promises.has(nonce))
|
|
224
|
+
return this.generateNonce(large);
|
|
225
|
+
return nonce;
|
|
220
226
|
}
|
|
221
227
|
generateSendPromise(nonce, message = 'Timeout') {
|
|
222
228
|
let resolve = (_) => {
|
|
223
229
|
/**/
|
|
224
230
|
};
|
|
231
|
+
let timeout = -1;
|
|
225
232
|
const promise = new Promise((res, rej) => {
|
|
226
233
|
resolve = res;
|
|
227
|
-
setTimeout(() => {
|
|
234
|
+
timeout = setTimeout(() => {
|
|
235
|
+
this.promises.delete(nonce);
|
|
228
236
|
rej(new Error(message));
|
|
229
237
|
}, 3e3);
|
|
230
238
|
});
|
|
231
|
-
this.promises.set(nonce, resolve);
|
|
239
|
+
this.promises.set(nonce, { resolve, timeout });
|
|
232
240
|
return promise;
|
|
233
241
|
}
|
|
234
242
|
async send(data, shardId) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "seyfert",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"module": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "tsc --outDir ./lib",
|
|
12
|
-
"dev": "swc src -d lib -w",
|
|
13
12
|
"prepublishOnly": "npm run build",
|
|
14
13
|
"prepare": "npm run build && husky install",
|
|
15
14
|
"lint": "biome lint --apply ./src",
|
|
@@ -20,36 +19,38 @@
|
|
|
20
19
|
"author": "MARCROCK22",
|
|
21
20
|
"license": "ISC",
|
|
22
21
|
"dependencies": {
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"ioredis": "^5.3.2",
|
|
28
|
-
"magic-bytes.js": "^1.7.0",
|
|
29
|
-
"ts-mixer": "^6.0.3",
|
|
22
|
+
"chokidar": "^3.6.0",
|
|
23
|
+
"discord-api-types": "^0.37.73",
|
|
24
|
+
"magic-bytes.js": "^1.10.0",
|
|
25
|
+
"ts-mixer": "^6.0.4",
|
|
30
26
|
"ws": "^8.16.0"
|
|
31
27
|
},
|
|
28
|
+
"lint-staged": {
|
|
29
|
+
"*.ts": [
|
|
30
|
+
"biome check --apply",
|
|
31
|
+
"biome format --write"
|
|
32
|
+
]
|
|
33
|
+
},
|
|
32
34
|
"devDependencies": {
|
|
33
|
-
"@biomejs/biome": "1.
|
|
34
|
-
"@
|
|
35
|
-
"@swc/core": "^1.3.102",
|
|
36
|
-
"@types/node": "^20.10.7",
|
|
35
|
+
"@biomejs/biome": "1.6.0",
|
|
36
|
+
"@types/node": "^20.11.25",
|
|
37
37
|
"@types/ws": "^8.5.10",
|
|
38
|
-
"husky": "^
|
|
39
|
-
"
|
|
40
|
-
"typescript": "^5.
|
|
38
|
+
"husky": "^9.0.11",
|
|
39
|
+
"lint-staged": "^15.2.2",
|
|
40
|
+
"typescript": "^5.4.2"
|
|
41
41
|
},
|
|
42
42
|
"optionalDependencies": {
|
|
43
|
+
"ioredis": "^5.3.2",
|
|
43
44
|
"tweetnacl": "^1.0.3",
|
|
44
|
-
"uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.
|
|
45
|
+
"uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.42.0"
|
|
45
46
|
},
|
|
46
|
-
"homepage": "https://
|
|
47
|
+
"homepage": "https://seyfert.dev",
|
|
47
48
|
"repository": {
|
|
48
49
|
"type": "git",
|
|
49
|
-
"url": "git+https://github.com/
|
|
50
|
+
"url": "git+https://github.com/tiramisulabs/seyfert.git"
|
|
50
51
|
},
|
|
51
52
|
"bugs": {
|
|
52
|
-
"url": "https://github.com/
|
|
53
|
+
"url": "https://github.com/tiramisulabs/seyfert"
|
|
53
54
|
},
|
|
54
55
|
"keywords": [
|
|
55
56
|
"api",
|
package/lib/api/REST.d.ts
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import type { Dispatcher } from 'undici-types';
|
|
2
|
-
import { Collection } from '../collection';
|
|
3
|
-
import { Logger } from '../common/it/logger';
|
|
4
|
-
import { CDN } from './CDN';
|
|
5
|
-
import type { ProxyRequestMethod } from './Router';
|
|
6
|
-
import type { IHandler } from './interfaces/Handler';
|
|
7
|
-
import type { HashData, InternalRequest, RESTConstructorOptions, RESTOptions, RawFile, RequestData, ResponseLike } from './utils/types';
|
|
8
|
-
/**
|
|
9
|
-
* Represents the class that manages handlers for endpoints
|
|
10
|
-
*/
|
|
11
|
-
export declare class REST {
|
|
12
|
-
#private;
|
|
13
|
-
/**
|
|
14
|
-
* The {@link https://undici.nodejs.org/#/docs/api/Agent | Agent} for all requests
|
|
15
|
-
* performed by this manager.
|
|
16
|
-
*/
|
|
17
|
-
agent: Dispatcher | null;
|
|
18
|
-
/**
|
|
19
|
-
* The number of requests remaining in the global bucket
|
|
20
|
-
*/
|
|
21
|
-
globalRemaining: number;
|
|
22
|
-
/**
|
|
23
|
-
* The promise used to wait out the global rate limit
|
|
24
|
-
*/
|
|
25
|
-
globalDelay: Promise<void> | null;
|
|
26
|
-
/**
|
|
27
|
-
* The timestamp at which the global bucket resets
|
|
28
|
-
*/
|
|
29
|
-
globalReset: number;
|
|
30
|
-
/**
|
|
31
|
-
* API bucket hashes that are cached from provided routes
|
|
32
|
-
*/
|
|
33
|
-
readonly hashes: Collection<string, HashData>;
|
|
34
|
-
/**
|
|
35
|
-
* Request handlers created from the bucket hash and the major parameters
|
|
36
|
-
*/
|
|
37
|
-
readonly handlers: Collection<string, IHandler>;
|
|
38
|
-
readonly cdn: CDN;
|
|
39
|
-
private hashTimer;
|
|
40
|
-
private handlerTimer;
|
|
41
|
-
readonly options: RESTOptions;
|
|
42
|
-
debugger?: Logger;
|
|
43
|
-
constructor(options: RESTConstructorOptions);
|
|
44
|
-
private setupSweepers;
|
|
45
|
-
/**
|
|
46
|
-
* Runs a get request from the api
|
|
47
|
-
*
|
|
48
|
-
* @param route - The full route to query
|
|
49
|
-
* @param options - Optional request options
|
|
50
|
-
*/
|
|
51
|
-
get<T>(route: string, options?: RequestObject<ProxyRequestMethod.Get>): Promise<T>;
|
|
52
|
-
/**
|
|
53
|
-
* Runs a delete request from the api
|
|
54
|
-
*
|
|
55
|
-
* @param route - The full route to query
|
|
56
|
-
* @param options - Optional request options
|
|
57
|
-
*/
|
|
58
|
-
delete<T>(route: string, options?: RequestObject<ProxyRequestMethod.Delete>): Promise<T>;
|
|
59
|
-
/**
|
|
60
|
-
* Runs a post request from the api
|
|
61
|
-
*
|
|
62
|
-
* @param route - The full route to query
|
|
63
|
-
* @param options - Optional request options
|
|
64
|
-
*/
|
|
65
|
-
post<T>(route: string, body?: RequestObject<ProxyRequestMethod.Post>): Promise<T>;
|
|
66
|
-
/**
|
|
67
|
-
* Runs a put request from the api
|
|
68
|
-
*
|
|
69
|
-
* @param route - The full route to query
|
|
70
|
-
* @param options - Optional request options
|
|
71
|
-
*/
|
|
72
|
-
put<T>(route: string, body?: RequestObject<ProxyRequestMethod.Put>): Promise<T>;
|
|
73
|
-
/**
|
|
74
|
-
* Runs a patch request from the api
|
|
75
|
-
*
|
|
76
|
-
* @param route - The full route to query
|
|
77
|
-
* @param options - Optional request options
|
|
78
|
-
*/
|
|
79
|
-
patch<T>(route: string, body?: RequestObject<ProxyRequestMethod.Patch>): Promise<T>;
|
|
80
|
-
/**
|
|
81
|
-
* Runs a request from the api
|
|
82
|
-
*
|
|
83
|
-
* @param options - Request options
|
|
84
|
-
*/
|
|
85
|
-
request(options: InternalRequest): Promise<unknown>;
|
|
86
|
-
/**
|
|
87
|
-
* Sets the default agent to use for requests performed by this manager
|
|
88
|
-
*
|
|
89
|
-
* @param agent - The agent to use
|
|
90
|
-
*/
|
|
91
|
-
setAgent(agent: Dispatcher): this;
|
|
92
|
-
/**
|
|
93
|
-
* Sets the authorization token that should be used for requests
|
|
94
|
-
*
|
|
95
|
-
* @param token - The authorization token to use
|
|
96
|
-
*/
|
|
97
|
-
setToken(token: string): this;
|
|
98
|
-
/**
|
|
99
|
-
* Queues a request to be sent
|
|
100
|
-
*
|
|
101
|
-
* @param request - All the information needed to make a request
|
|
102
|
-
* @returns The response from the api request
|
|
103
|
-
*/
|
|
104
|
-
queueRequest(request: InternalRequest): Promise<ResponseLike>;
|
|
105
|
-
/**
|
|
106
|
-
* Formats the request data to a usable format for fetch
|
|
107
|
-
*
|
|
108
|
-
* @param request - The request data
|
|
109
|
-
*/
|
|
110
|
-
private resolveRequest;
|
|
111
|
-
/**
|
|
112
|
-
* Stops the hash sweeping interval
|
|
113
|
-
*/
|
|
114
|
-
clearHashSweeper(): void;
|
|
115
|
-
/**
|
|
116
|
-
* Stops the request handler sweeping interval
|
|
117
|
-
*/
|
|
118
|
-
clearHandlerSweeper(): void;
|
|
119
|
-
}
|
|
120
|
-
export type RequestOptions = Pick<RequestData, 'passThroughBody' | 'reason' | 'auth' | 'appendToFormData'>;
|
|
121
|
-
export type RequestObject<M extends ProxyRequestMethod, B = Record<string, any>, Q = Record<string, any>, F extends RawFile[] = RawFile[]> = {
|
|
122
|
-
query?: Q;
|
|
123
|
-
} & RequestOptions & (M extends `${ProxyRequestMethod.Get}` ? unknown : {
|
|
124
|
-
body?: B;
|
|
125
|
-
files?: F;
|
|
126
|
-
});
|
|
127
|
-
export type RestArguments<M extends ProxyRequestMethod, B = any, Q extends never | Record<string, any> = any, F extends RawFile[] = RawFile[]> = M extends ProxyRequestMethod.Get ? Q extends never ? RequestObject<M, never, B, never> : never : RequestObject<M, B, Q, F>;
|