seyfert 1.2.2 → 1.2.3
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/LICENSE +190 -190
- package/README.md +46 -46
- package/lib/api/Router.d.ts +9 -0
- package/lib/api/Router.js +16 -8
- package/lib/api/Routes/cdn.d.ts +26 -15
- package/lib/api/api.d.ts +2 -3
- package/lib/api/api.js +4 -9
- package/lib/api/index.d.ts +0 -1
- package/lib/api/index.js +0 -1
- package/lib/builders/Modal.d.ts +4 -1
- package/lib/builders/Modal.js +4 -1
- package/lib/cache/adapters/default.d.ts +1 -0
- package/lib/cache/adapters/default.js +4 -0
- package/lib/cache/adapters/redis.d.ts +2 -0
- package/lib/cache/adapters/redis.js +17 -0
- package/lib/cache/adapters/types.d.ts +1 -0
- package/lib/cache/adapters/workeradapter.d.ts +1 -0
- package/lib/cache/adapters/workeradapter.js +6 -9
- package/lib/cache/index.d.ts +3 -1
- package/lib/cache/index.js +3 -0
- package/lib/cache/resources/overwrites.d.ts +2 -0
- package/lib/client/base.d.ts +1 -1
- package/lib/client/base.js +8 -5
- package/lib/client/onmessagecreate.js +15 -12
- package/lib/client/workerclient.js +5 -11
- package/lib/commands/applications/chat.d.ts +9 -6
- package/lib/commands/applications/chat.js +4 -1
- package/lib/commands/applications/shared.d.ts +4 -0
- package/lib/commands/applications/shared.js +6 -0
- package/lib/commands/decorators.d.ts +11 -1
- package/lib/commands/decorators.js +24 -0
- package/lib/common/shorters/channels.d.ts +3 -0
- package/lib/common/shorters/channels.js +3 -2
- package/lib/common/types/options.d.ts +2 -2
- package/lib/structures/GuildEmoji.d.ts +2 -2
- package/lib/structures/GuildEmoji.js +1 -1
- package/lib/structures/GuildMember.js +1 -1
- package/lib/structures/User.d.ts +2 -3
- package/lib/structures/User.js +8 -3
- package/lib/structures/Webhook.js +1 -1
- package/lib/structures/channels.d.ts +5 -0
- package/lib/structures/extra/BaseGuild.js +3 -3
- package/lib/websocket/discord/worker.d.ts +1 -1
- package/lib/websocket/discord/workermanager.js +3 -9
- package/lib/websocket/structures/timeout.js +9 -12
- package/package.json +1 -1
- package/lib/api/CDN.d.ts +0 -212
- package/lib/api/CDN.js +0 -228
- package/lib/client/http/adapters/bun.d.ts +0 -14
- package/lib/client/http/adapters/bun.js +0 -117
- package/lib/client/http/adapters/index.d.ts +0 -15
- package/lib/client/http/adapters/index.js +0 -27
- package/lib/client/http/adapters/uws.d.ts +0 -17
- package/lib/client/http/adapters/uws.js +0 -142
- package/lib/client/http/httpclient.d.ts +0 -13
- package/lib/client/http/httpclient.js +0 -48
- package/lib/common/shorters/overwrites.d.ts +0 -29
- package/lib/common/shorters/overwrites.js +0 -63
- package/lib/components/listener.d.ts +0 -11
- package/lib/components/listener.js +0 -17
- package/lib/structures/extra/BaseComponent.d.ts +0 -9
- package/lib/structures/extra/BaseComponent.js +0 -12
- package/lib/structures/extra/BaseSelectMenuComponent.d.ts +0 -9
- package/lib/structures/extra/BaseSelectMenuComponent.js +0 -13
|
@@ -23,7 +23,7 @@ class GuildEmoji extends DiscordBase_1.DiscordBase {
|
|
|
23
23
|
return this.client.emojis.fetch(this.guildId, this.id, force);
|
|
24
24
|
}
|
|
25
25
|
url(options) {
|
|
26
|
-
return this.rest.cdn.
|
|
26
|
+
return this.rest.cdn.emojis(this.id).get(options);
|
|
27
27
|
}
|
|
28
28
|
toString() {
|
|
29
29
|
return `<${this.animated ? 'a' : ''}:${this.name}:${this.id}>`;
|
|
@@ -127,7 +127,7 @@ class GuildMember extends BaseGuildMember {
|
|
|
127
127
|
if (!this.avatar) {
|
|
128
128
|
return this.user.avatarURL(options);
|
|
129
129
|
}
|
|
130
|
-
return this.rest.cdn.
|
|
130
|
+
return this.rest.cdn.guilds(this.guildId).users(this.id).avatars(this.avatar).get(options);
|
|
131
131
|
}
|
|
132
132
|
bannerURL(options) {
|
|
133
133
|
return this.user.bannerURL(options);
|
package/lib/structures/User.d.ts
CHANGED
|
@@ -17,11 +17,10 @@ export declare class User extends DiscordBase<APIUser> {
|
|
|
17
17
|
dm(force?: boolean): Promise<import("./channels").DMChannel>;
|
|
18
18
|
write(body: MessageCreateBodyRequest): Promise<import("./Message").Message>;
|
|
19
19
|
avatarURL(options?: ImageOptions): string;
|
|
20
|
+
avatarDecorationURL(options?: ImageOptions): string | undefined;
|
|
20
21
|
bannerURL(options?: ImageOptions): string | undefined;
|
|
21
22
|
presence(): import("..").ReturnCache<(Omit<import("discord-api-types/v10").GatewayPresenceUpdate, "user"> & {
|
|
22
|
-
id: string;
|
|
23
|
-
* Fetch user
|
|
24
|
-
*/
|
|
23
|
+
id: string;
|
|
25
24
|
} & {
|
|
26
25
|
guild_id: string;
|
|
27
26
|
}) | undefined>;
|
package/lib/structures/User.js
CHANGED
|
@@ -27,14 +27,19 @@ class User extends DiscordBase_1.DiscordBase {
|
|
|
27
27
|
avatarURL(options) {
|
|
28
28
|
if (!this.avatar) {
|
|
29
29
|
const avatarIndex = this.discriminator === '0' ? Number(BigInt(this.id) >> 22n) % 6 : Number.parseInt(this.discriminator) % 5;
|
|
30
|
-
return this.rest.cdn.
|
|
30
|
+
return this.rest.cdn.embed.avatars.get(avatarIndex);
|
|
31
31
|
}
|
|
32
|
-
return this.rest.cdn.
|
|
32
|
+
return this.rest.cdn.avatars(this.id).get(this.avatar, options);
|
|
33
|
+
}
|
|
34
|
+
avatarDecorationURL(options) {
|
|
35
|
+
if (!this.avatarDecoration)
|
|
36
|
+
return;
|
|
37
|
+
return this.rest.cdn['avatar-decorations'](this.id).get(this.avatarDecoration, options);
|
|
33
38
|
}
|
|
34
39
|
bannerURL(options) {
|
|
35
40
|
if (!this.banner)
|
|
36
41
|
return;
|
|
37
|
-
return this.rest.cdn.
|
|
42
|
+
return this.rest.cdn.banners(this.id).get(this.banner, options);
|
|
38
43
|
}
|
|
39
44
|
presence() {
|
|
40
45
|
return this.client.members.presence(this.id);
|
|
@@ -60,7 +60,7 @@ class Webhook extends DiscordBase_1.DiscordBase {
|
|
|
60
60
|
if (!this.avatar) {
|
|
61
61
|
return null;
|
|
62
62
|
}
|
|
63
|
-
return this.rest.cdn.
|
|
63
|
+
return this.rest.cdn.avatars(this.id).get(this.avatar, options);
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
66
|
* Fetches the webhook data from the Discord API.
|
|
@@ -64,12 +64,14 @@ export declare class BaseGuildChannel extends BaseChannel<ChannelType> {
|
|
|
64
64
|
id: string;
|
|
65
65
|
deny: import("./extra/Permissions").PermissionsBitField;
|
|
66
66
|
allow: import("./extra/Permissions").PermissionsBitField;
|
|
67
|
+
guildId: string;
|
|
67
68
|
}[] | undefined>;
|
|
68
69
|
values: () => {
|
|
69
70
|
type: number;
|
|
70
71
|
id: string;
|
|
71
72
|
deny: import("./extra/Permissions").PermissionsBitField;
|
|
72
73
|
allow: import("./extra/Permissions").PermissionsBitField;
|
|
74
|
+
guildId: string;
|
|
73
75
|
}[][];
|
|
74
76
|
};
|
|
75
77
|
memberPermissions(member: GuildMember, checkAdmin?: boolean): Promise<import("./extra/Permissions").PermissionsBitField>;
|
|
@@ -80,18 +82,21 @@ export declare class BaseGuildChannel extends BaseChannel<ChannelType> {
|
|
|
80
82
|
id: string;
|
|
81
83
|
deny: import("./extra/Permissions").PermissionsBitField;
|
|
82
84
|
allow: import("./extra/Permissions").PermissionsBitField;
|
|
85
|
+
guildId: string;
|
|
83
86
|
} | undefined;
|
|
84
87
|
roles: {
|
|
85
88
|
type: number;
|
|
86
89
|
id: string;
|
|
87
90
|
deny: import("./extra/Permissions").PermissionsBitField;
|
|
88
91
|
allow: import("./extra/Permissions").PermissionsBitField;
|
|
92
|
+
guildId: string;
|
|
89
93
|
}[];
|
|
90
94
|
member: {
|
|
91
95
|
type: number;
|
|
92
96
|
id: string;
|
|
93
97
|
deny: import("./extra/Permissions").PermissionsBitField;
|
|
94
98
|
allow: import("./extra/Permissions").PermissionsBitField;
|
|
99
|
+
guildId: string;
|
|
95
100
|
} | undefined;
|
|
96
101
|
}>;
|
|
97
102
|
guild(force?: boolean): Promise<import("./Guild").Guild<"cached"> | import("./Guild").Guild<"api">>;
|
|
@@ -38,7 +38,7 @@ class BaseGuild extends DiscordBase_1.DiscordBase {
|
|
|
38
38
|
if (!this.icon) {
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
|
-
return this.rest.cdn.
|
|
41
|
+
return this.rest.cdn.icons(this.id).get(this.icon, options);
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
44
|
* splashURL gets the current guild splash as a string.
|
|
@@ -50,7 +50,7 @@ class BaseGuild extends DiscordBase_1.DiscordBase {
|
|
|
50
50
|
if (!this.splash) {
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
|
-
return this.rest.cdn
|
|
53
|
+
return this.rest.cdn['discovery-splashes'](this.id).get(this.splash, options);
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
56
|
* bannerURL gets the current guild banner as a string.
|
|
@@ -62,7 +62,7 @@ class BaseGuild extends DiscordBase_1.DiscordBase {
|
|
|
62
62
|
if (!this.banner) {
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
|
-
return this.rest.cdn.
|
|
65
|
+
return this.rest.cdn.banners(this.id).get(this.banner, options);
|
|
66
66
|
}
|
|
67
67
|
toString() {
|
|
68
68
|
return this.name;
|
|
@@ -25,7 +25,7 @@ export type WorkerSendResultPayload = CreateWorkerMessage<'RESULT_PAYLOAD', {
|
|
|
25
25
|
}>;
|
|
26
26
|
export type WorkerSendCacheRequest = CreateWorkerMessage<'CACHE_REQUEST', {
|
|
27
27
|
nonce: string;
|
|
28
|
-
method: 'scan' | 'get' | 'set' | 'patch' | 'values' | 'keys' | 'count' | 'remove' | 'contains' | 'getToRelationship' | 'bulkAddToRelationShip' | 'addToRelationship' | 'removeRelationship' | 'removeToRelationship';
|
|
28
|
+
method: 'scan' | 'get' | 'set' | 'patch' | 'values' | 'keys' | 'count' | 'remove' | 'flush' | 'contains' | 'getToRelationship' | 'bulkAddToRelationShip' | 'addToRelationship' | 'removeRelationship' | 'removeToRelationship';
|
|
29
29
|
args: any[];
|
|
30
30
|
}>;
|
|
31
31
|
export type WorkerSendShardInfo = CreateWorkerMessage<'SHARD_INFO', WorkerShardInfo & {
|
|
@@ -310,19 +310,13 @@ class WorkerManager extends Map {
|
|
|
310
310
|
return nonce;
|
|
311
311
|
}
|
|
312
312
|
generateSendPromise(nonce, message = 'Timeout') {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
};
|
|
316
|
-
let timeout = -1;
|
|
317
|
-
const promise = new Promise((res, rej) => {
|
|
318
|
-
resolve = res;
|
|
319
|
-
timeout = setTimeout(() => {
|
|
313
|
+
return new Promise((res, rej) => {
|
|
314
|
+
const timeout = setTimeout(() => {
|
|
320
315
|
this.promises.delete(nonce);
|
|
321
316
|
rej(new Error(message));
|
|
322
317
|
}, 60e3);
|
|
318
|
+
this.promises.set(nonce, { resolve: res, timeout });
|
|
323
319
|
});
|
|
324
|
-
this.promises.set(nonce, { resolve, timeout });
|
|
325
|
-
return promise;
|
|
326
320
|
}
|
|
327
321
|
async send(data, shardId) {
|
|
328
322
|
const workerId = this.calculateWorkerId(shardId);
|
|
@@ -9,18 +9,15 @@ class ConnectTimeout {
|
|
|
9
9
|
this.intervalTime = intervalTime;
|
|
10
10
|
}
|
|
11
11
|
wait() {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
this.promises.push(resolve);
|
|
23
|
-
return promise;
|
|
12
|
+
return new Promise(res => {
|
|
13
|
+
if (!this.promises.length) {
|
|
14
|
+
this.interval = setInterval(() => {
|
|
15
|
+
this.shift();
|
|
16
|
+
}, this.intervalTime);
|
|
17
|
+
res(true);
|
|
18
|
+
}
|
|
19
|
+
this.promises.push(res);
|
|
20
|
+
});
|
|
24
21
|
}
|
|
25
22
|
shift() {
|
|
26
23
|
this.promises.shift()?.(true);
|
package/package.json
CHANGED
package/lib/api/CDN.d.ts
DELETED
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import { type ImageExtension, type ImageSize, type StickerExtension } from './utils/constants.js';
|
|
2
|
-
/**
|
|
3
|
-
* The options used for image URLs
|
|
4
|
-
*/
|
|
5
|
-
export interface BaseImageURLOptions {
|
|
6
|
-
/**
|
|
7
|
-
* The extension to use for the image URL
|
|
8
|
-
*
|
|
9
|
-
* @defaultValue `'webp'`
|
|
10
|
-
*/
|
|
11
|
-
extension?: ImageExtension;
|
|
12
|
-
/**
|
|
13
|
-
* The size specified in the image URL
|
|
14
|
-
*/
|
|
15
|
-
size?: ImageSize;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* The options used for image URLs with animated content
|
|
19
|
-
*/
|
|
20
|
-
export interface ImageURLOptions extends BaseImageURLOptions {
|
|
21
|
-
/**
|
|
22
|
-
* Whether or not to prefer the static version of an image asset.
|
|
23
|
-
*/
|
|
24
|
-
forceStatic?: boolean;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* The options to use when making a CDN URL
|
|
28
|
-
*/
|
|
29
|
-
export interface MakeURLOptions {
|
|
30
|
-
/**
|
|
31
|
-
* The allowed extensions that can be used
|
|
32
|
-
*/
|
|
33
|
-
allowedExtensions?: readonly string[];
|
|
34
|
-
/**
|
|
35
|
-
* The extension to use for the image URL
|
|
36
|
-
*
|
|
37
|
-
* @defaultValue `'webp'`
|
|
38
|
-
*/
|
|
39
|
-
extension?: ImageExtension | StickerExtension | undefined;
|
|
40
|
-
/**
|
|
41
|
-
* The size specified in the image URL
|
|
42
|
-
*/
|
|
43
|
-
size?: ImageSize;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* The CDN link builder
|
|
47
|
-
*/
|
|
48
|
-
export declare class CDN {
|
|
49
|
-
private readonly base;
|
|
50
|
-
constructor(base?: string);
|
|
51
|
-
/**
|
|
52
|
-
* Generates an app asset URL for a client's asset.
|
|
53
|
-
*
|
|
54
|
-
* @param clientId - The client id that has the asset
|
|
55
|
-
* @param assetHash - The hash provided by Discord for this asset
|
|
56
|
-
* @param options - Optional options for the asset
|
|
57
|
-
*/
|
|
58
|
-
appAsset(clientId: string, assetHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
|
59
|
-
/**
|
|
60
|
-
* Generates an app icon URL for a client's icon.
|
|
61
|
-
*
|
|
62
|
-
* @param clientId - The client id that has the icon
|
|
63
|
-
* @param iconHash - The hash provided by Discord for this icon
|
|
64
|
-
* @param options - Optional options for the icon
|
|
65
|
-
*/
|
|
66
|
-
appIcon(clientId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
|
67
|
-
/**
|
|
68
|
-
* Generates an avatar URL, e.g. for a user or a webhook.
|
|
69
|
-
*
|
|
70
|
-
* @param id - The id that has the icon
|
|
71
|
-
* @param avatarHash - The hash provided by Discord for this avatar
|
|
72
|
-
* @param options - Optional options for the avatar
|
|
73
|
-
*/
|
|
74
|
-
avatar(id: string, avatarHash: string, options?: Readonly<ImageURLOptions>): string;
|
|
75
|
-
/**
|
|
76
|
-
* Generates a user avatar decoration URL.
|
|
77
|
-
*
|
|
78
|
-
* @param userId - The id of the user
|
|
79
|
-
* @param userAvatarDecoration - The hash provided by Discord for this avatar decoration
|
|
80
|
-
* @param options - Optional options for the avatar decoration
|
|
81
|
-
*/
|
|
82
|
-
avatarDecoration(userId: string, userAvatarDecoration: string, options?: Readonly<BaseImageURLOptions>): string;
|
|
83
|
-
/**
|
|
84
|
-
* Generates a banner URL, e.g. for a user or a guild.
|
|
85
|
-
*
|
|
86
|
-
* @param id - The id that has the banner splash
|
|
87
|
-
* @param bannerHash - The hash provided by Discord for this banner
|
|
88
|
-
* @param options - Optional options for the banner
|
|
89
|
-
*/
|
|
90
|
-
banner(id: string, bannerHash: string, options?: Readonly<ImageURLOptions>): string;
|
|
91
|
-
/**
|
|
92
|
-
* Generates an icon URL for a channel, e.g. a group DM.
|
|
93
|
-
*
|
|
94
|
-
* @param channelId - The channel id that has the icon
|
|
95
|
-
* @param iconHash - The hash provided by Discord for this channel
|
|
96
|
-
* @param options - Optional options for the icon
|
|
97
|
-
*/
|
|
98
|
-
channelIcon(channelId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
|
99
|
-
/**
|
|
100
|
-
* Generates a default avatar URL
|
|
101
|
-
*
|
|
102
|
-
* @param index - The default avatar index
|
|
103
|
-
* @remarks
|
|
104
|
-
* To calculate the index for a user do `(userId >> 22) % 6`,
|
|
105
|
-
* or `discriminator % 5` if they're using the legacy username system.
|
|
106
|
-
*/
|
|
107
|
-
defaultAvatar(index: number): string;
|
|
108
|
-
/**
|
|
109
|
-
* Generates a discovery splash URL for a guild's discovery splash.
|
|
110
|
-
*
|
|
111
|
-
* @param guildId - The guild id that has the discovery splash
|
|
112
|
-
* @param splashHash - The hash provided by Discord for this splash
|
|
113
|
-
* @param options - Optional options for the splash
|
|
114
|
-
*/
|
|
115
|
-
discoverySplash(guildId: string, splashHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
|
116
|
-
/**
|
|
117
|
-
* Generates an emoji's URL for an emoji.
|
|
118
|
-
*
|
|
119
|
-
* @param emojiId - The emoji id
|
|
120
|
-
* @param options - Optional options for the emoji
|
|
121
|
-
*/
|
|
122
|
-
emoji(emojiId: string, options?: Readonly<BaseImageURLOptions>): string;
|
|
123
|
-
/**
|
|
124
|
-
* Generates a guild member avatar URL.
|
|
125
|
-
*
|
|
126
|
-
* @param guildId - The id of the guild
|
|
127
|
-
* @param userId - The id of the user
|
|
128
|
-
* @param avatarHash - The hash provided by Discord for this avatar
|
|
129
|
-
* @param options - Optional options for the avatar
|
|
130
|
-
*/
|
|
131
|
-
guildMemberAvatar(guildId: string, userId: string, avatarHash: string, options?: Readonly<ImageURLOptions>): string;
|
|
132
|
-
/**
|
|
133
|
-
* Generates a guild member banner URL.
|
|
134
|
-
*
|
|
135
|
-
* @param guildId - The id of the guild
|
|
136
|
-
* @param userId - The id of the user
|
|
137
|
-
* @param bannerHash - The hash provided by Discord for this banner
|
|
138
|
-
* @param options - Optional options for the banner
|
|
139
|
-
*/
|
|
140
|
-
guildMemberBanner(guildId: string, userId: string, bannerHash: string, options?: Readonly<ImageURLOptions>): string;
|
|
141
|
-
/**
|
|
142
|
-
* Generates an icon URL, e.g. for a guild.
|
|
143
|
-
*
|
|
144
|
-
* @param id - The id that has the icon splash
|
|
145
|
-
* @param iconHash - The hash provided by Discord for this icon
|
|
146
|
-
* @param options - Optional options for the icon
|
|
147
|
-
*/
|
|
148
|
-
icon(id: string, iconHash: string, options?: Readonly<ImageURLOptions>): string;
|
|
149
|
-
/**
|
|
150
|
-
* Generates a URL for the icon of a role
|
|
151
|
-
*
|
|
152
|
-
* @param roleId - The id of the role that has the icon
|
|
153
|
-
* @param roleIconHash - The hash provided by Discord for this role icon
|
|
154
|
-
* @param options - Optional options for the role icon
|
|
155
|
-
*/
|
|
156
|
-
roleIcon(roleId: string, roleIconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
|
157
|
-
/**
|
|
158
|
-
* Generates a guild invite splash URL for a guild's invite splash.
|
|
159
|
-
*
|
|
160
|
-
* @param guildId - The guild id that has the invite splash
|
|
161
|
-
* @param splashHash - The hash provided by Discord for this splash
|
|
162
|
-
* @param options - Optional options for the splash
|
|
163
|
-
*/
|
|
164
|
-
splash(guildId: string, splashHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
|
165
|
-
/**
|
|
166
|
-
* Generates a sticker URL.
|
|
167
|
-
*
|
|
168
|
-
* @param stickerId - The sticker id
|
|
169
|
-
* @param extension - The extension of the sticker
|
|
170
|
-
* @privateRemarks
|
|
171
|
-
* Stickers cannot have a `.webp` extension, so we default to a `.png`
|
|
172
|
-
*/
|
|
173
|
-
sticker(stickerId: string, extension?: StickerExtension): string;
|
|
174
|
-
/**
|
|
175
|
-
* Generates a sticker pack banner URL.
|
|
176
|
-
*
|
|
177
|
-
* @param bannerId - The banner id
|
|
178
|
-
* @param options - Optional options for the banner
|
|
179
|
-
*/
|
|
180
|
-
stickerPackBanner(bannerId: string, options?: Readonly<BaseImageURLOptions>): string;
|
|
181
|
-
/**
|
|
182
|
-
* Generates a team icon URL for a team's icon.
|
|
183
|
-
*
|
|
184
|
-
* @param teamId - The team id that has the icon
|
|
185
|
-
* @param iconHash - The hash provided by Discord for this icon
|
|
186
|
-
* @param options - Optional options for the icon
|
|
187
|
-
*/
|
|
188
|
-
teamIcon(teamId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
|
189
|
-
/**
|
|
190
|
-
* Generates a cover image for a guild scheduled event.
|
|
191
|
-
*
|
|
192
|
-
* @param scheduledEventId - The scheduled event id
|
|
193
|
-
* @param coverHash - The hash provided by discord for this cover image
|
|
194
|
-
* @param options - Optional options for the cover image
|
|
195
|
-
*/
|
|
196
|
-
guildScheduledEventCover(scheduledEventId: string, coverHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
|
197
|
-
/**
|
|
198
|
-
* Constructs the URL for the resource, checking whether or not `hash` starts with `a_` if `dynamic` is set to `true`.
|
|
199
|
-
*
|
|
200
|
-
* @param route - The base cdn route
|
|
201
|
-
* @param hash - The hash provided by Discord for this icon
|
|
202
|
-
* @param options - Optional options for the link
|
|
203
|
-
*/
|
|
204
|
-
private dynamicMakeURL;
|
|
205
|
-
/**
|
|
206
|
-
* Constructs the URL for the resource
|
|
207
|
-
*
|
|
208
|
-
* @param route - The base cdn route
|
|
209
|
-
* @param options - The extension/size options for the link
|
|
210
|
-
*/
|
|
211
|
-
private makeURL;
|
|
212
|
-
}
|
package/lib/api/CDN.js
DELETED
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CDN = void 0;
|
|
4
|
-
/* eslint-disable jsdoc/check-param-names */
|
|
5
|
-
const index_js_1 = require("../common/index.js");
|
|
6
|
-
const constants_js_1 = require("./utils/constants.js");
|
|
7
|
-
/**
|
|
8
|
-
* The CDN link builder
|
|
9
|
-
*/
|
|
10
|
-
class CDN {
|
|
11
|
-
base;
|
|
12
|
-
constructor(base = index_js_1.CDN_URL) {
|
|
13
|
-
this.base = base;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Generates an app asset URL for a client's asset.
|
|
17
|
-
*
|
|
18
|
-
* @param clientId - The client id that has the asset
|
|
19
|
-
* @param assetHash - The hash provided by Discord for this asset
|
|
20
|
-
* @param options - Optional options for the asset
|
|
21
|
-
*/
|
|
22
|
-
appAsset(clientId, assetHash, options) {
|
|
23
|
-
return this.makeURL(`/app-assets/${clientId}/${assetHash}`, options);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Generates an app icon URL for a client's icon.
|
|
27
|
-
*
|
|
28
|
-
* @param clientId - The client id that has the icon
|
|
29
|
-
* @param iconHash - The hash provided by Discord for this icon
|
|
30
|
-
* @param options - Optional options for the icon
|
|
31
|
-
*/
|
|
32
|
-
appIcon(clientId, iconHash, options) {
|
|
33
|
-
return this.makeURL(`/app-icons/${clientId}/${iconHash}`, options);
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Generates an avatar URL, e.g. for a user or a webhook.
|
|
37
|
-
*
|
|
38
|
-
* @param id - The id that has the icon
|
|
39
|
-
* @param avatarHash - The hash provided by Discord for this avatar
|
|
40
|
-
* @param options - Optional options for the avatar
|
|
41
|
-
*/
|
|
42
|
-
avatar(id, avatarHash, options) {
|
|
43
|
-
return this.dynamicMakeURL(`/avatars/${id}/${avatarHash}`, avatarHash, options);
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Generates a user avatar decoration URL.
|
|
47
|
-
*
|
|
48
|
-
* @param userId - The id of the user
|
|
49
|
-
* @param userAvatarDecoration - The hash provided by Discord for this avatar decoration
|
|
50
|
-
* @param options - Optional options for the avatar decoration
|
|
51
|
-
*/
|
|
52
|
-
avatarDecoration(userId, userAvatarDecoration, options) {
|
|
53
|
-
return this.makeURL(`/avatar-decorations/${userId}/${userAvatarDecoration}`, options);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Generates a banner URL, e.g. for a user or a guild.
|
|
57
|
-
*
|
|
58
|
-
* @param id - The id that has the banner splash
|
|
59
|
-
* @param bannerHash - The hash provided by Discord for this banner
|
|
60
|
-
* @param options - Optional options for the banner
|
|
61
|
-
*/
|
|
62
|
-
banner(id, bannerHash, options) {
|
|
63
|
-
return this.dynamicMakeURL(`/banners/${id}/${bannerHash}`, bannerHash, options);
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Generates an icon URL for a channel, e.g. a group DM.
|
|
67
|
-
*
|
|
68
|
-
* @param channelId - The channel id that has the icon
|
|
69
|
-
* @param iconHash - The hash provided by Discord for this channel
|
|
70
|
-
* @param options - Optional options for the icon
|
|
71
|
-
*/
|
|
72
|
-
channelIcon(channelId, iconHash, options) {
|
|
73
|
-
return this.makeURL(`/channel-icons/${channelId}/${iconHash}`, options);
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Generates a default avatar URL
|
|
77
|
-
*
|
|
78
|
-
* @param index - The default avatar index
|
|
79
|
-
* @remarks
|
|
80
|
-
* To calculate the index for a user do `(userId >> 22) % 6`,
|
|
81
|
-
* or `discriminator % 5` if they're using the legacy username system.
|
|
82
|
-
*/
|
|
83
|
-
defaultAvatar(index) {
|
|
84
|
-
return this.makeURL(`/embed/avatars/${index}`, { extension: 'png' });
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Generates a discovery splash URL for a guild's discovery splash.
|
|
88
|
-
*
|
|
89
|
-
* @param guildId - The guild id that has the discovery splash
|
|
90
|
-
* @param splashHash - The hash provided by Discord for this splash
|
|
91
|
-
* @param options - Optional options for the splash
|
|
92
|
-
*/
|
|
93
|
-
discoverySplash(guildId, splashHash, options) {
|
|
94
|
-
return this.makeURL(`/discovery-splashes/${guildId}/${splashHash}`, options);
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Generates an emoji's URL for an emoji.
|
|
98
|
-
*
|
|
99
|
-
* @param emojiId - The emoji id
|
|
100
|
-
* @param options - Optional options for the emoji
|
|
101
|
-
*/
|
|
102
|
-
emoji(emojiId, options) {
|
|
103
|
-
const resolvedOptions = options;
|
|
104
|
-
return this.makeURL(`/emojis/${emojiId}`, resolvedOptions);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Generates a guild member avatar URL.
|
|
108
|
-
*
|
|
109
|
-
* @param guildId - The id of the guild
|
|
110
|
-
* @param userId - The id of the user
|
|
111
|
-
* @param avatarHash - The hash provided by Discord for this avatar
|
|
112
|
-
* @param options - Optional options for the avatar
|
|
113
|
-
*/
|
|
114
|
-
guildMemberAvatar(guildId, userId, avatarHash, options) {
|
|
115
|
-
return this.dynamicMakeURL(`/guilds/${guildId}/users/${userId}/avatars/${avatarHash}`, avatarHash, options);
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Generates a guild member banner URL.
|
|
119
|
-
*
|
|
120
|
-
* @param guildId - The id of the guild
|
|
121
|
-
* @param userId - The id of the user
|
|
122
|
-
* @param bannerHash - The hash provided by Discord for this banner
|
|
123
|
-
* @param options - Optional options for the banner
|
|
124
|
-
*/
|
|
125
|
-
guildMemberBanner(guildId, userId, bannerHash, options) {
|
|
126
|
-
return this.dynamicMakeURL(`/guilds/${guildId}/users/${userId}/banner`, bannerHash, options);
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Generates an icon URL, e.g. for a guild.
|
|
130
|
-
*
|
|
131
|
-
* @param id - The id that has the icon splash
|
|
132
|
-
* @param iconHash - The hash provided by Discord for this icon
|
|
133
|
-
* @param options - Optional options for the icon
|
|
134
|
-
*/
|
|
135
|
-
icon(id, iconHash, options) {
|
|
136
|
-
return this.dynamicMakeURL(`/icons/${id}/${iconHash}`, iconHash, options);
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Generates a URL for the icon of a role
|
|
140
|
-
*
|
|
141
|
-
* @param roleId - The id of the role that has the icon
|
|
142
|
-
* @param roleIconHash - The hash provided by Discord for this role icon
|
|
143
|
-
* @param options - Optional options for the role icon
|
|
144
|
-
*/
|
|
145
|
-
roleIcon(roleId, roleIconHash, options) {
|
|
146
|
-
return this.makeURL(`/role-icons/${roleId}/${roleIconHash}`, options);
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Generates a guild invite splash URL for a guild's invite splash.
|
|
150
|
-
*
|
|
151
|
-
* @param guildId - The guild id that has the invite splash
|
|
152
|
-
* @param splashHash - The hash provided by Discord for this splash
|
|
153
|
-
* @param options - Optional options for the splash
|
|
154
|
-
*/
|
|
155
|
-
splash(guildId, splashHash, options) {
|
|
156
|
-
return this.makeURL(`/splashes/${guildId}/${splashHash}`, options);
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Generates a sticker URL.
|
|
160
|
-
*
|
|
161
|
-
* @param stickerId - The sticker id
|
|
162
|
-
* @param extension - The extension of the sticker
|
|
163
|
-
* @privateRemarks
|
|
164
|
-
* Stickers cannot have a `.webp` extension, so we default to a `.png`
|
|
165
|
-
*/
|
|
166
|
-
sticker(stickerId, extension = 'png') {
|
|
167
|
-
return this.makeURL(`/stickers/${stickerId}`, { allowedExtensions: constants_js_1.ALLOWED_STICKER_EXTENSIONS, extension });
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Generates a sticker pack banner URL.
|
|
171
|
-
*
|
|
172
|
-
* @param bannerId - The banner id
|
|
173
|
-
* @param options - Optional options for the banner
|
|
174
|
-
*/
|
|
175
|
-
stickerPackBanner(bannerId, options) {
|
|
176
|
-
return this.makeURL(`/app-assets/710982414301790216/store/${bannerId}`, options);
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Generates a team icon URL for a team's icon.
|
|
180
|
-
*
|
|
181
|
-
* @param teamId - The team id that has the icon
|
|
182
|
-
* @param iconHash - The hash provided by Discord for this icon
|
|
183
|
-
* @param options - Optional options for the icon
|
|
184
|
-
*/
|
|
185
|
-
teamIcon(teamId, iconHash, options) {
|
|
186
|
-
return this.makeURL(`/team-icons/${teamId}/${iconHash}`, options);
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Generates a cover image for a guild scheduled event.
|
|
190
|
-
*
|
|
191
|
-
* @param scheduledEventId - The scheduled event id
|
|
192
|
-
* @param coverHash - The hash provided by discord for this cover image
|
|
193
|
-
* @param options - Optional options for the cover image
|
|
194
|
-
*/
|
|
195
|
-
guildScheduledEventCover(scheduledEventId, coverHash, options) {
|
|
196
|
-
return this.makeURL(`/guild-events/${scheduledEventId}/${coverHash}`, options);
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Constructs the URL for the resource, checking whether or not `hash` starts with `a_` if `dynamic` is set to `true`.
|
|
200
|
-
*
|
|
201
|
-
* @param route - The base cdn route
|
|
202
|
-
* @param hash - The hash provided by Discord for this icon
|
|
203
|
-
* @param options - Optional options for the link
|
|
204
|
-
*/
|
|
205
|
-
dynamicMakeURL(route, hash, { forceStatic = false, ...options } = {}) {
|
|
206
|
-
return this.makeURL(route, !forceStatic && hash.startsWith('a_') ? { ...options, extension: 'gif' } : options);
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Constructs the URL for the resource
|
|
210
|
-
*
|
|
211
|
-
* @param route - The base cdn route
|
|
212
|
-
* @param options - The extension/size options for the link
|
|
213
|
-
*/
|
|
214
|
-
makeURL(route, { allowedExtensions = constants_js_1.ALLOWED_EXTENSIONS, extension = 'webp', size } = {}) {
|
|
215
|
-
if (!allowedExtensions.includes(extension)) {
|
|
216
|
-
throw new RangeError(`Invalid extension provided: ${extension}\nMust be one of: ${allowedExtensions.join(', ')}`);
|
|
217
|
-
}
|
|
218
|
-
if (size && !constants_js_1.ALLOWED_SIZES.includes(size)) {
|
|
219
|
-
throw new RangeError(`Invalid size provided: ${size}\nMust be one of: ${constants_js_1.ALLOWED_SIZES.join(', ')}`);
|
|
220
|
-
}
|
|
221
|
-
const url = new URL(`${this.base}${route}.${extension}`);
|
|
222
|
-
if (size) {
|
|
223
|
-
url.searchParams.set('size', String(size));
|
|
224
|
-
}
|
|
225
|
-
return url.toString();
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
exports.CDN = CDN;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { HttpAdapter } from ".";
|
|
2
|
-
import { Logger } from "../../../common";
|
|
3
|
-
import { HttpClient } from "../httpclient";
|
|
4
|
-
export declare class HttpBunAdapter extends HttpAdapter {
|
|
5
|
-
app: ReturnType<typeof Bun.serve>;
|
|
6
|
-
constructor(options: {
|
|
7
|
-
client: HttpClient;
|
|
8
|
-
debugger?: Logger;
|
|
9
|
-
logger: Logger;
|
|
10
|
-
});
|
|
11
|
-
listen(): void;
|
|
12
|
-
verifySignature(req: Request): Promise<any>;
|
|
13
|
-
onPacket(req: Request): Promise<Response>;
|
|
14
|
-
}
|