@discordeno/utils 19.0.0-next.f98bb9b → 19.0.0-next.f9bdfce
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 +6 -143
- package/dist/cjs/Collection.cjs +123 -0
- package/dist/cjs/base64.cjs +276 -0
- package/dist/cjs/bucket.cjs +96 -0
- package/dist/cjs/builders/embeds.cjs +292 -0
- package/dist/cjs/builders.cjs +27 -0
- package/dist/cjs/casing.cjs +75 -0
- package/dist/cjs/colors.cjs +456 -0
- package/dist/cjs/hash.cjs +37 -0
- package/dist/cjs/images.cjs +136 -0
- package/dist/cjs/index.cjs +36 -0
- package/dist/cjs/logger.cjs +157 -0
- package/dist/cjs/oauth2.cjs +26 -0
- package/dist/cjs/permissions.cjs +35 -0
- package/dist/cjs/reactions.cjs +21 -0
- package/dist/cjs/token.cjs +39 -0
- package/dist/cjs/typeguards.cjs +45 -0
- package/dist/cjs/urlToBase64.cjs +19 -0
- package/dist/cjs/urls.cjs +26 -0
- package/dist/cjs/utils.cjs +30 -0
- package/dist/esm/Collection.js +113 -0
- package/dist/esm/base64.js +262 -0
- package/dist/esm/bucket.js +81 -0
- package/dist/esm/builders/embeds.js +295 -0
- package/dist/esm/builders.js +5 -0
- package/dist/esm/casing.js +51 -0
- package/dist/esm/colors.js +467 -0
- package/dist/esm/hash.js +19 -0
- package/dist/esm/images.js +179 -0
- package/dist/esm/index.js +19 -0
- package/dist/esm/logger.js +130 -0
- package/dist/esm/oauth2.js +16 -0
- package/dist/esm/permissions.js +17 -0
- package/dist/esm/reactions.js +11 -0
- package/dist/esm/token.js +21 -0
- package/dist/esm/typeguards.js +18 -0
- package/dist/esm/urlToBase64.js +9 -0
- package/dist/esm/urls.js +8 -0
- package/dist/esm/utils.js +15 -0
- package/dist/{Collection.d.ts → types/Collection.d.ts} +2 -3
- package/dist/types/Collection.d.ts.map +1 -0
- package/dist/types/base64.d.ts.map +1 -0
- package/dist/{bucket.d.ts → types/bucket.d.ts} +9 -2
- package/dist/types/bucket.d.ts.map +1 -0
- package/dist/{builders → types/builders}/embeds.d.ts +17 -17
- package/dist/types/builders/embeds.d.ts.map +1 -0
- package/dist/types/builders.d.ts.map +1 -0
- package/dist/types/casing.d.ts.map +1 -0
- package/dist/types/colors.d.ts.map +1 -0
- package/dist/types/hash.d.ts.map +1 -0
- package/dist/types/images.d.ts +202 -0
- package/dist/types/images.d.ts.map +1 -0
- package/dist/{index.d.ts → types/index.d.ts} +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/logger.d.ts.map +1 -0
- package/dist/{oauth2.d.ts → types/oauth2.d.ts} +12 -1
- package/dist/types/oauth2.d.ts.map +1 -0
- package/dist/types/permissions.d.ts.map +1 -0
- package/dist/types/reactions.d.ts.map +1 -0
- package/dist/types/token.d.ts.map +1 -0
- package/dist/types/typeguards.d.ts.map +1 -0
- package/dist/types/urlToBase64.d.ts.map +1 -0
- package/dist/types/urls.d.ts +4 -0
- package/dist/types/urls.d.ts.map +1 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/package.json +27 -22
- package/dist/Collection.d.ts.map +0 -1
- package/dist/Collection.js +0 -113
- package/dist/Collection.js.map +0 -1
- package/dist/base64.d.ts.map +0 -1
- package/dist/base64.js +0 -262
- package/dist/base64.js.map +0 -1
- package/dist/bucket.d.ts.map +0 -1
- package/dist/bucket.js +0 -76
- package/dist/bucket.js.map +0 -1
- package/dist/builders/embeds.d.ts.map +0 -1
- package/dist/builders/embeds.js +0 -295
- package/dist/builders/embeds.js.map +0 -1
- package/dist/builders.d.ts.map +0 -1
- package/dist/builders.js +0 -5
- package/dist/builders.js.map +0 -1
- package/dist/casing.d.ts.map +0 -1
- package/dist/casing.js +0 -51
- package/dist/casing.js.map +0 -1
- package/dist/colors.d.ts.map +0 -1
- package/dist/colors.js +0 -467
- package/dist/colors.js.map +0 -1
- package/dist/hash.d.ts.map +0 -1
- package/dist/hash.js +0 -19
- package/dist/hash.js.map +0 -1
- package/dist/images.d.ts +0 -68
- package/dist/images.d.ts.map +0 -1
- package/dist/images.js +0 -66
- package/dist/images.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -18
- package/dist/index.js.map +0 -1
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -130
- package/dist/logger.js.map +0 -1
- package/dist/oauth2.d.ts.map +0 -1
- package/dist/oauth2.js +0 -16
- package/dist/oauth2.js.map +0 -1
- package/dist/permissions.d.ts.map +0 -1
- package/dist/permissions.js +0 -17
- package/dist/permissions.js.map +0 -1
- package/dist/reactions.d.ts.map +0 -1
- package/dist/reactions.js +0 -11
- package/dist/reactions.js.map +0 -1
- package/dist/token.d.ts.map +0 -1
- package/dist/token.js +0 -21
- package/dist/token.js.map +0 -1
- package/dist/typeguards.d.ts.map +0 -1
- package/dist/typeguards.js +0 -18
- package/dist/typeguards.js.map +0 -1
- package/dist/urlToBase64.d.ts.map +0 -1
- package/dist/urlToBase64.js +0 -9
- package/dist/urlToBase64.js.map +0 -1
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -15
- package/dist/utils.js.map +0 -1
- /package/dist/{base64.d.ts → types/base64.d.ts} +0 -0
- /package/dist/{builders.d.ts → types/builders.d.ts} +0 -0
- /package/dist/{casing.d.ts → types/casing.d.ts} +0 -0
- /package/dist/{colors.d.ts → types/colors.d.ts} +0 -0
- /package/dist/{hash.d.ts → types/hash.d.ts} +0 -0
- /package/dist/{logger.d.ts → types/logger.d.ts} +0 -0
- /package/dist/{permissions.d.ts → types/permissions.d.ts} +0 -0
- /package/dist/{reactions.d.ts → types/reactions.d.ts} +0 -0
- /package/dist/{token.d.ts → types/token.d.ts} +0 -0
- /package/dist/{typeguards.d.ts → types/typeguards.d.ts} +0 -0
- /package/dist/{urlToBase64.d.ts → types/urlToBase64.d.ts} +0 -0
- /package/dist/{utils.d.ts → types/utils.d.ts} +0 -0
|
@@ -23,13 +23,13 @@ export declare class EmbedsBuilder extends Array<DiscordEmbed> {
|
|
|
23
23
|
* @param {?boolean} [inline=false] - Field should be inline or not.
|
|
24
24
|
* @returns {EmbedsBuilder}
|
|
25
25
|
*/
|
|
26
|
-
addField(name: string, value: string, inline?: boolean):
|
|
26
|
+
addField(name: string, value: string, inline?: boolean): this;
|
|
27
27
|
/**
|
|
28
28
|
* Creates a blank embed.
|
|
29
29
|
*
|
|
30
30
|
* @returns {EmbedsBuilder}
|
|
31
31
|
*/
|
|
32
|
-
newEmbed():
|
|
32
|
+
newEmbed(): this;
|
|
33
33
|
/**
|
|
34
34
|
* Set the current embed author.
|
|
35
35
|
*
|
|
@@ -37,14 +37,14 @@ export declare class EmbedsBuilder extends Array<DiscordEmbed> {
|
|
|
37
37
|
* @param {?Omit<DiscordEmbedAuthor, 'name'>} [options] - Extra author options
|
|
38
38
|
* @returns {EmbedsBuilder}
|
|
39
39
|
*/
|
|
40
|
-
setAuthor(name: string, options?: Omit<DiscordEmbedAuthor, 'name'>):
|
|
40
|
+
setAuthor(name: string, options?: Omit<DiscordEmbedAuthor, 'name'>): this;
|
|
41
41
|
/**
|
|
42
42
|
* Set the color on the side of the current embed.
|
|
43
43
|
*
|
|
44
44
|
* @param {(number | string)} color - The color, in base16 or hex color code
|
|
45
45
|
* @returns {EmbedsBuilder}
|
|
46
46
|
*/
|
|
47
|
-
setColor(color: number | string):
|
|
47
|
+
setColor(color: number | string): this;
|
|
48
48
|
/**
|
|
49
49
|
* Set the current embed to a different index.
|
|
50
50
|
*
|
|
@@ -53,21 +53,21 @@ export declare class EmbedsBuilder extends Array<DiscordEmbed> {
|
|
|
53
53
|
* @param {?number} [index] - The index of the embed in the EmbedsBuilder array
|
|
54
54
|
* @returns {EmbedsBuilder}
|
|
55
55
|
*/
|
|
56
|
-
setCurrentEmbed(index?: number):
|
|
56
|
+
setCurrentEmbed(index?: number): this;
|
|
57
57
|
/**
|
|
58
58
|
* Set the description of the current embed.
|
|
59
59
|
*
|
|
60
60
|
* @param {string} description - Description
|
|
61
61
|
* @returns {EmbedsBuilder}
|
|
62
62
|
*/
|
|
63
|
-
setDescription(description: string):
|
|
63
|
+
setDescription(description: string): this;
|
|
64
64
|
/**
|
|
65
65
|
* Overwrite all fields on the current embed.
|
|
66
66
|
*
|
|
67
67
|
* @param {DiscordEmbedField[]} fields
|
|
68
68
|
* @returns {EmbedsBuilder}
|
|
69
69
|
*/
|
|
70
|
-
setFields(fields: DiscordEmbedField[]):
|
|
70
|
+
setFields(fields: DiscordEmbedField[]): this;
|
|
71
71
|
/**
|
|
72
72
|
* Set the footer in the current embed.
|
|
73
73
|
*
|
|
@@ -75,7 +75,7 @@ export declare class EmbedsBuilder extends Array<DiscordEmbed> {
|
|
|
75
75
|
* @param {?Omit<DiscordEmbedFooter, 'text'>} [options]
|
|
76
76
|
* @returns {EmbedsBuilder}
|
|
77
77
|
*/
|
|
78
|
-
setFooter(text: string, options?: Omit<DiscordEmbedFooter, 'text'>):
|
|
78
|
+
setFooter(text: string, options?: Omit<DiscordEmbedFooter, 'text'>): this;
|
|
79
79
|
/**
|
|
80
80
|
* Set the image in the current embed.
|
|
81
81
|
*
|
|
@@ -83,7 +83,7 @@ export declare class EmbedsBuilder extends Array<DiscordEmbed> {
|
|
|
83
83
|
* @param {?Omit<DiscordEmbedImage, 'url'>} [options]
|
|
84
84
|
* @returns {EmbedsBuilder}
|
|
85
85
|
*/
|
|
86
|
-
setImage(url: string, options?: Omit<DiscordEmbedImage, 'url'>):
|
|
86
|
+
setImage(url: string, options?: Omit<DiscordEmbedImage, 'url'>): this;
|
|
87
87
|
/**
|
|
88
88
|
* Set the provider of the current embed.
|
|
89
89
|
*
|
|
@@ -91,13 +91,13 @@ export declare class EmbedsBuilder extends Array<DiscordEmbed> {
|
|
|
91
91
|
* @param {?string} [url]
|
|
92
92
|
* @returns {EmbedsBuilder}
|
|
93
93
|
*/
|
|
94
|
-
setProvider(name: string, url?: string):
|
|
94
|
+
setProvider(name: string, url?: string): this;
|
|
95
95
|
/**
|
|
96
96
|
* Set the color of the current embed to a random value.
|
|
97
97
|
*
|
|
98
98
|
* @returns {EmbedsBuilder}
|
|
99
99
|
*/
|
|
100
|
-
setRandomColor():
|
|
100
|
+
setRandomColor(): this;
|
|
101
101
|
/**
|
|
102
102
|
* Set the title of the current embed.
|
|
103
103
|
*
|
|
@@ -105,14 +105,14 @@ export declare class EmbedsBuilder extends Array<DiscordEmbed> {
|
|
|
105
105
|
* @param {?string} [url]
|
|
106
106
|
* @returns {EmbedsBuilder}
|
|
107
107
|
*/
|
|
108
|
-
setTitle(title: string, url?: string):
|
|
108
|
+
setTitle(title: string, url?: string): this;
|
|
109
109
|
/**
|
|
110
110
|
* Set the timestamp of the current embed.
|
|
111
111
|
*
|
|
112
112
|
* @param {?(string | number | Date)} [timestamp]
|
|
113
113
|
* @returns {EmbedsBuilder}
|
|
114
114
|
*/
|
|
115
|
-
setTimestamp(timestamp?: string | number | Date):
|
|
115
|
+
setTimestamp(timestamp?: string | number | Date): this;
|
|
116
116
|
/**
|
|
117
117
|
* Set the thumbnail of the current embed.
|
|
118
118
|
*
|
|
@@ -120,14 +120,14 @@ export declare class EmbedsBuilder extends Array<DiscordEmbed> {
|
|
|
120
120
|
* @param {?Omit<DiscordEmbedThumbnail, 'url'>} [options]
|
|
121
121
|
* @returns {EmbedsBuilder}
|
|
122
122
|
*/
|
|
123
|
-
setThumbnail(url: string, options?: Omit<DiscordEmbedThumbnail, 'url'>):
|
|
123
|
+
setThumbnail(url: string, options?: Omit<DiscordEmbedThumbnail, 'url'>): this;
|
|
124
124
|
/**
|
|
125
125
|
* Set the URL of the current embed title.
|
|
126
126
|
*
|
|
127
127
|
* @param {string} url
|
|
128
128
|
* @returns {EmbedsBuilder}
|
|
129
129
|
*/
|
|
130
|
-
setUrl(url: string):
|
|
130
|
+
setUrl(url: string): this;
|
|
131
131
|
/**
|
|
132
132
|
* Set the video of the current embed.
|
|
133
133
|
*
|
|
@@ -135,12 +135,12 @@ export declare class EmbedsBuilder extends Array<DiscordEmbed> {
|
|
|
135
135
|
* @param {?Omit<DiscordEmbedVideo, 'url'>} [options]
|
|
136
136
|
* @returns {EmbedsBuilder}
|
|
137
137
|
*/
|
|
138
|
-
setVideo(url: string, options?: Omit<DiscordEmbedVideo, 'url'>):
|
|
138
|
+
setVideo(url: string, options?: Omit<DiscordEmbedVideo, 'url'>): this;
|
|
139
139
|
/**
|
|
140
140
|
* Validate all embeds available against current known Discord limits to help prevent bad requests.
|
|
141
141
|
*
|
|
142
142
|
* @returns {EmbedsBuilder}
|
|
143
143
|
*/
|
|
144
|
-
validate():
|
|
144
|
+
validate(): this;
|
|
145
145
|
}
|
|
146
146
|
//# sourceMappingURL=embeds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embeds.d.ts","sourceRoot":"","sources":["../../../src/builders/embeds.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,mBAAmB,CAAA;AAE1B;;;;;;;;;;;;;GAaG;AACH,qBAAa,aAAc,SAAQ,KAAK,CAAC,YAAY,CAAC;;IAGpD;;;;;;;OAOG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI;IAc7D;;;;OAIG;IACH,QAAQ,IAAI,IAAI;IAWhB;;;;;;OAMG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,GAAG,IAAI;IAUzE;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAWtC;;;;;;;OAOG;IACH,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI;IAgBrC;;;;;OAKG;IACH,cAAc,CA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sBAAsB,CAAA;AAEpC,eAAO,MAAM,YAAY,QAAO,aAAoC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"casing.d.ts","sourceRoot":"","sources":["../../src/casing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAE5D,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAclD;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAcpD;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAepD;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAapD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../src/colors.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf;AAED,qEAAqE;AACrE,MAAM,WAAW,GAAG;IAClB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAID;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,QAE7C;AAED,4DAA4D;AAC5D,wBAAgB,eAAe,IAAI,OAAO,CAEzC;AAwBD;;;GAGG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEzC;AAED;;;GAGG;AACH,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAExC;AAED;;;GAGG;AACH,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,M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import { type BigString, type GetGuildWidgetImageQuery, type ImageFormat, type ImageSize, StickerFormatTypes } from '@discordeno/types';
|
|
2
|
+
/** Help format an image url. */
|
|
3
|
+
export declare function formatImageUrl(url: string, size?: ImageSize, format?: ImageFormat): string;
|
|
4
|
+
/**
|
|
5
|
+
* Get the url for an emoji.
|
|
6
|
+
*
|
|
7
|
+
* @param emojiId The id of the emoji
|
|
8
|
+
* @param animated Whether or not the emoji is animated
|
|
9
|
+
* @returns string
|
|
10
|
+
*/
|
|
11
|
+
export declare function emojiUrl(emojiId: BigString, animated?: boolean): string;
|
|
12
|
+
/**
|
|
13
|
+
* Builds a URL to a user's avatar stored in the Discord CDN.
|
|
14
|
+
*
|
|
15
|
+
* @param userId - The ID of the user to get the avatar of.
|
|
16
|
+
* @param discriminator - The user's discriminator. (4-digit tag after the hashtag.)
|
|
17
|
+
* @param options - The parameters for the building of the URL.
|
|
18
|
+
* @returns The link to the resource.
|
|
19
|
+
*/
|
|
20
|
+
export declare function avatarUrl(userId: BigString, discriminator: string, options?: {
|
|
21
|
+
avatar: BigString | undefined;
|
|
22
|
+
size?: ImageSize;
|
|
23
|
+
format?: ImageFormat;
|
|
24
|
+
}): string;
|
|
25
|
+
export declare function avatarDecorationUrl(avatarDecoration: BigString): string;
|
|
26
|
+
/**
|
|
27
|
+
* Builds a URL to a user's banner stored in the Discord CDN.
|
|
28
|
+
*
|
|
29
|
+
* @param userId - The ID of the user to get the banner of.
|
|
30
|
+
* @param options - The parameters for the building of the URL.
|
|
31
|
+
* @returns The link to the resource or `undefined` if no banner has not been set.
|
|
32
|
+
*/
|
|
33
|
+
export declare function bannerUrl(userId: BigString, options?: {
|
|
34
|
+
banner?: BigString;
|
|
35
|
+
size?: ImageSize;
|
|
36
|
+
format?: ImageFormat;
|
|
37
|
+
}): string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Builds a URL to the guild banner stored in the Discord CDN.
|
|
40
|
+
*
|
|
41
|
+
* @param guildId - The ID of the guild to get the link to the banner for.
|
|
42
|
+
* @param options - The parameters for the building of the URL.
|
|
43
|
+
* @returns The link to the resource or `undefined` if no banner has been set.
|
|
44
|
+
*/
|
|
45
|
+
export declare function guildBannerUrl(guildId: BigString, options: {
|
|
46
|
+
banner?: BigString;
|
|
47
|
+
size?: ImageSize;
|
|
48
|
+
format?: ImageFormat;
|
|
49
|
+
}): string | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Builds a URL to the guild icon stored in the Discord CDN.
|
|
52
|
+
*
|
|
53
|
+
* @param guildId - The ID of the guild to get the link to the banner for.
|
|
54
|
+
* @param imageHash - The hash identifying the event cover image.
|
|
55
|
+
* @param options - The parameters for the building of the URL.
|
|
56
|
+
* @returns The link to the resource or `undefined` if no banner has been set.
|
|
57
|
+
*/
|
|
58
|
+
export declare function guildIconUrl(guildId: BigString, imageHash: BigString | undefined, options?: {
|
|
59
|
+
size?: ImageSize;
|
|
60
|
+
format?: ImageFormat;
|
|
61
|
+
}): string | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* Builds the URL to a guild splash stored in the Discord CDN.
|
|
64
|
+
*
|
|
65
|
+
* @param guildId - The ID of the guild to get the splash of.
|
|
66
|
+
* @param imageHash - The hash identifying the splash image.
|
|
67
|
+
* @param options - The parameters for the building of the URL.
|
|
68
|
+
* @returns The link to the resource or `undefined` if the guild does not have a splash image set.
|
|
69
|
+
*/
|
|
70
|
+
export declare function guildSplashUrl(guildId: BigString, imageHash: BigString | undefined, options?: {
|
|
71
|
+
size?: ImageSize;
|
|
72
|
+
format?: ImageFormat;
|
|
73
|
+
}): string | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* Builds the URL to a guild discovery splash stored in the Discord CDN.
|
|
76
|
+
*
|
|
77
|
+
* @param guildId - The ID of the guild to get the splash of.
|
|
78
|
+
* @param imageHash - The hash identifying the discovery splash image.
|
|
79
|
+
* @param options - The parameters for the building of the URL.
|
|
80
|
+
* @returns The link to the resource or `undefined` if the guild does not have a splash image set.
|
|
81
|
+
*/
|
|
82
|
+
export declare function guildDiscoverySplashUrl(guildId: BigString, imageHash: BigString | undefined, options?: {
|
|
83
|
+
size?: ImageSize;
|
|
84
|
+
format?: ImageFormat;
|
|
85
|
+
}): string | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* Builds the URL to a guild scheduled event cover stored in the Discord CDN.
|
|
88
|
+
*
|
|
89
|
+
* @param eventId - The ID of the scheduled event to get the cover of.
|
|
90
|
+
* @param options - The parameters for the building of the URL.
|
|
91
|
+
* @returns The link to the resource or `undefined`.
|
|
92
|
+
*/
|
|
93
|
+
export declare function guildScheduledEventCoverUrl(eventId: BigString, options: {
|
|
94
|
+
cover?: BigString;
|
|
95
|
+
size?: ImageSize;
|
|
96
|
+
format?: ImageFormat;
|
|
97
|
+
}): string | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* Builds a URL to the guild widget image stored in the Discord CDN.
|
|
100
|
+
*
|
|
101
|
+
* @param guildId - The ID of the guild to get the link to the widget image for.
|
|
102
|
+
* @param options - The parameters for the building of the URL.
|
|
103
|
+
* @returns The link to the resource.
|
|
104
|
+
*/
|
|
105
|
+
export declare function getWidgetImageUrl(guildId: BigString, options?: GetGuildWidgetImageQuery): string;
|
|
106
|
+
/**
|
|
107
|
+
* Builds a URL to a member's avatar stored in the Discord CDN.
|
|
108
|
+
*
|
|
109
|
+
* @param guildId - The ID of the guild where the member is
|
|
110
|
+
* @param userId - The ID of the user to get the avatar of.
|
|
111
|
+
* @param options - The parameters for the building of the URL.
|
|
112
|
+
* @returns The link to the resource or `undefined` if no banner has been set.
|
|
113
|
+
*/
|
|
114
|
+
export declare function memberAvatarUrl(guildId: BigString, userId: BigString, options?: {
|
|
115
|
+
avatar?: BigString;
|
|
116
|
+
size?: ImageSize;
|
|
117
|
+
format?: ImageFormat;
|
|
118
|
+
}): string | undefined;
|
|
119
|
+
/**
|
|
120
|
+
* Builds the URL to an application icon stored in the Discord CDN.
|
|
121
|
+
*
|
|
122
|
+
* @param applicationId - The ID of the application to get the icon of.
|
|
123
|
+
* @param iconHash - The hash identifying the application icon.
|
|
124
|
+
* @param options - The parameters for the building of the URL.
|
|
125
|
+
* @returns The link to the resource or `undefined`
|
|
126
|
+
*/
|
|
127
|
+
export declare function applicationIconUrl(applicationId: BigString, iconHash: BigString | undefined, options?: {
|
|
128
|
+
size?: ImageSize;
|
|
129
|
+
format?: ImageFormat;
|
|
130
|
+
}): string | undefined;
|
|
131
|
+
/**
|
|
132
|
+
* Builds the URL to an application cover stored in the Discord CDN.
|
|
133
|
+
*
|
|
134
|
+
* @param applicationId - The ID of the application to get the cover of.
|
|
135
|
+
* @param coverHash - The hash identifying the application cover.
|
|
136
|
+
* @param options - The parameters for the building of the URL.
|
|
137
|
+
* @returns The link to the resource or `undefined`.
|
|
138
|
+
*/
|
|
139
|
+
export declare function applicationCoverUrl(applicationId: BigString, coverHash: BigString | undefined, options?: {
|
|
140
|
+
size?: ImageSize;
|
|
141
|
+
format?: ImageFormat;
|
|
142
|
+
}): string | undefined;
|
|
143
|
+
/**
|
|
144
|
+
* Builds the URL to an application asset stored in the Discord CDN.
|
|
145
|
+
*
|
|
146
|
+
* @param applicationId - The ID of the application to get the asset of.
|
|
147
|
+
* @param assetId - The id identifying the application asset.
|
|
148
|
+
* @param options - The parameters for the building of the URL.
|
|
149
|
+
* @returns The link to the resource or `undefined`.
|
|
150
|
+
*/
|
|
151
|
+
export declare function applicationAssetUrl(applicationId: BigString, assetId: BigString | undefined, options?: {
|
|
152
|
+
size?: ImageSize;
|
|
153
|
+
format?: ImageFormat;
|
|
154
|
+
}): string | undefined;
|
|
155
|
+
/**
|
|
156
|
+
* Builds the URL to a sticker pack banner stored in the Discord CDN.
|
|
157
|
+
*
|
|
158
|
+
* @param bannerAssetId - The ID of the banner asset for the sticker pack.
|
|
159
|
+
* @param options - The parameters for the building of the URL.
|
|
160
|
+
* @returns The link to the resource or `undefined`.
|
|
161
|
+
*/
|
|
162
|
+
export declare function stickerPackBannerUrl(bannerAssetId: BigString | undefined, options?: {
|
|
163
|
+
size?: ImageSize;
|
|
164
|
+
format?: ImageFormat;
|
|
165
|
+
}): string | undefined;
|
|
166
|
+
/**
|
|
167
|
+
* Builds the URL to a sticker stored in the Discord CDN.
|
|
168
|
+
*
|
|
169
|
+
* @param stickerId - The ID of the sticker to get the icon of
|
|
170
|
+
* @param options - The parameters for the building of the URL.
|
|
171
|
+
* @returns The link to the resource or `undefined`.
|
|
172
|
+
*/
|
|
173
|
+
export declare function stickerUrl(stickerId: BigString | number, options?: {
|
|
174
|
+
size?: ImageSize;
|
|
175
|
+
format?: ImageFormat;
|
|
176
|
+
type?: StickerFormatTypes;
|
|
177
|
+
}): string | undefined;
|
|
178
|
+
/**
|
|
179
|
+
* Builds the URL to a team icon stored in the Discord CDN.
|
|
180
|
+
*
|
|
181
|
+
* @param teamId - The ID of the team to get the icon of
|
|
182
|
+
* @param iconHash - The hash of the team icon.
|
|
183
|
+
* @param options - The parameters for the building of the URL.
|
|
184
|
+
* @returns The link to the resource or `undefined`.
|
|
185
|
+
*/
|
|
186
|
+
export declare function teamIconUrl(teamId: BigString, iconHash: BigString | undefined, options?: {
|
|
187
|
+
size?: ImageSize;
|
|
188
|
+
format?: ImageFormat;
|
|
189
|
+
}): string | undefined;
|
|
190
|
+
/**
|
|
191
|
+
* Builds the URL to a role icon stored in the Discord CDN.
|
|
192
|
+
*
|
|
193
|
+
* @param roleId - The ID of the role to get the icon of
|
|
194
|
+
* @param iconHash - The hash of the role icon.
|
|
195
|
+
* @param options - The parameters for the building of the URL.
|
|
196
|
+
* @returns The link to the resource or `undefined`.
|
|
197
|
+
*/
|
|
198
|
+
export declare function roleIconUrl(roleId: BigString, iconHash: BigString | undefined, options?: {
|
|
199
|
+
size?: ImageSize;
|
|
200
|
+
format?: ImageFormat;
|
|
201
|
+
}): string | undefined;
|
|
202
|
+
//# sourceMappingURL=images.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"images.d.ts","sourceRoot":"","s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C,EAAE;IACR,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB,GACA,MAAM,GAAG,SAAS,CAQpB;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,SAAS,GAAG,SAAS,EAC/B,OAAO,CAAC,EAAE;IACR,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB,GACA,MAAM,GAAG,SAAS,CAQpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAKA,oBAAY,SAAS;IACnB,KAAK,IAAA;IACL,IAAI,IAAA;IACJ,IAAI,IAAA;IACJ,KAAK,IAAA;IACL,KAAK,IAAA;CACN;AAED,oBAAY,QAAQ;IAClB,OAAO,IAAA;IACP,IAAI,IAAA;CACL;AAmBD,wBAAgB,YAAY,CAAC,EAC3B,QAAyB,EACzB,IAAI,GACL,GAAE;IACD,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;CACT;iBAGgB,SAAS,WAAW,GAAG,EAAE;sBAkCpB,QAAQ;sBAJR,SAAS;qBAQV,GAAG,EAAE;oBAKN,GAAG,EAAE;oBAKL,GAAG,EAAE;qBAKJ,GAAG,EAAE;qBAKL,GAAG,EAAE;EAe9B;AAED,eAAO,MAAM,MAAM;iBA3EG,SAAS,WAAW,GAAG,EAAE;sBAkCpB,QAAQ;sBAJR,SAAS;qBAQV,GAAG,EAAE;oBAKN,GAAG,EAAE;oBAKL,GAAG,EAAE;qBAKJ,GAAG,EAAE;qBAKL,GAAG,EAAE;CAiB2B,CAAA;AAC1D,eAAe,MAAM,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BigString, OAuth2Scope, PermissionStrings } from '@discordeno/types';
|
|
1
|
+
import type { BigString, DiscordApplicationIntegrationType, OAuth2Scope, PermissionStrings } from '@discordeno/types';
|
|
2
2
|
export declare function createOAuth2Link(options: CreateOAuth2LinkOptions): string;
|
|
3
3
|
export interface CreateOAuth2LinkOptions {
|
|
4
4
|
/**
|
|
@@ -54,5 +54,16 @@ export interface CreateOAuth2LinkOptions {
|
|
|
54
54
|
* Should be defined only in a [bot authorization flow](https://discord.com/developers/docs/topics/oauth2#bot-authorization-flow), with [advanced bot authorization](https://discord.com/developers/docs/topics/oauth2#advanced-bot-authorization) or with the `webhook.incoming` scope
|
|
55
55
|
*/
|
|
56
56
|
disableGuildSelect?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Specifies the installation context for the authorization
|
|
59
|
+
*
|
|
60
|
+
* @remarks
|
|
61
|
+
* Should be defined only when {@link scope} includes {@link OAuth2Scope.ApplicationsCommands}.
|
|
62
|
+
*
|
|
63
|
+
* When set to GuildInstall (0) the application will be authorized for installation to a server, and when set to UserInstall (1) the application will be authorized for installation to a user.
|
|
64
|
+
*
|
|
65
|
+
* The application must be configured in the Developer Portal to support the provided `integrationType`.
|
|
66
|
+
*/
|
|
67
|
+
integrationType?: DiscordApplicationIntegrationType;
|
|
57
68
|
}
|
|
58
69
|
//# sourceMappingURL=oauth2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth2.d.ts","sourceRoot":"","sources":["../../src/oauth2.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,iCAAiC,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAGrH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,MAAM,CAezE;AAED,MAAM,WAAW,uBAAuB;IACtC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IAC/B,gCAAgC;IAChC,QAAQ,EAAE,SAAS,CAAA;IACnB,qCAAqC;IACrC,KAAK,EAAE,WAAW,EAAE,CAAA;IACpB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,SAAS,GAAG,MAAM,CAAA;IAC3B;;;;;OAKG;IACH,WAAW,CAAC,EAAE,SAAS,GAAG,iBAAiB,EAAE,CAAA;IAC7C;;;;;OAKG;IACH,OAAO,CAAC,EAAE,SAAS,CAAA;IACnB;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B;;;;;;;;;OASG;IACH,eAAe,CAAC,EAAE,iCAAiC,CAAA;CACpD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../src/permissions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAG1D,oEAAoE;AACpE,wBAAgB,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAOhF;AAED,8EAA8E;AAC9E,wBAAgB,aAAa,CAAC,WAAW,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAOtE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactions.d.ts","sourceRoot":"","sources":["../../src/reactions.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAU9D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../src/token.ts"],"names":[],"mappings":"AAIA,+CAA+C;AAC/C,wBAAgB,iBAAiB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,IAAI,GAAE,SAAS,GAAG,MAAe,GAAG,MAAM,CAY3F;AAED,0LAA0L;AAC1L,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEvD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeguards.d.ts","sourceRoot":"","sources":["../../src/typeguards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,mBAAmB,CAAA;AAG1B,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,IAAI,gBAAgB,CAE3F;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,IAAI,iBAAiB,CAE7F;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,IAAI,iBAAiB,CAE7F;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,IAAI,gBAAgB,CAE3F;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,GAAG,qBAAqB,GAAG,OAAO,IAAI,qBAAqB,CAE3H"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"urlToBase64.d.ts","sourceRoot":"","sources":["../../src/urlToBase64.ts"],"names":[],"mappings":"AAEA,uFAAuF;AACvF,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAK9D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"urls.d.ts","sourceRoot":"","sources":["../../src/urls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAElD,wBAAgB,OAAO,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,GAAG,MAAM,CAElE;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAElD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,wBAAsB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAQrD;AAID,6DAA6D;AAE7D,wBAAgB,WAAW,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,WAAW,GAAG,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAGxH"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@discordeno/utils",
|
|
3
|
-
"version": "19.0.0-next.
|
|
4
|
-
"main": "./dist/index.js",
|
|
5
|
-
"
|
|
3
|
+
"version": "19.0.0-next.f9bdfce",
|
|
4
|
+
"main": "./dist/esm/index.js",
|
|
5
|
+
"exports": {
|
|
6
|
+
"import": "./dist/esm/index.js",
|
|
7
|
+
"require": "./dist/cjs/index.cjs",
|
|
8
|
+
"types": "./dist/types/index.d.ts"
|
|
9
|
+
},
|
|
10
|
+
"types": "./dist/types/index.d.ts",
|
|
6
11
|
"type": "module",
|
|
7
12
|
"license": "Apache-2.0",
|
|
8
13
|
"repository": {
|
|
@@ -10,37 +15,37 @@
|
|
|
10
15
|
"url": "https://github.com/discordeno/discordeno.git"
|
|
11
16
|
},
|
|
12
17
|
"scripts": {
|
|
13
|
-
"build": "swc --delete-dir-on-start src --out-dir dist",
|
|
14
|
-
"build:type": "tsc --skipDefaultLibCheck --declaration --emitDeclarationOnly --declarationDir dist",
|
|
18
|
+
"build": "swc src --strip-leading-paths --delete-dir-on-start src --out-dir dist/esm && swc --strip-leading-paths --delete-dir-on-start src --out-dir dist/cjs -C module.type=commonjs && node ../../scripts/fixCjsExtension.js",
|
|
19
|
+
"build:type": "tsc --skipDefaultLibCheck --declaration --emitDeclarationOnly --declarationDir dist/types",
|
|
15
20
|
"release-build": "yarn build && yarn build:type",
|
|
16
21
|
"fmt": "eslint --fix \"src/**/*.ts*\"",
|
|
17
22
|
"lint": "eslint \"src/**/*.ts*\"",
|
|
18
23
|
"test:unit-coverage": "c8 mocha --no-warnings 'tests/**/*.spec.ts'",
|
|
19
24
|
"test:unit": "c8 --r lcov mocha --no-warnings 'tests/**/*.spec.ts' && node ../../scripts/coveragePathFixing.js utils",
|
|
20
|
-
"test:deno-unit": "swc tests --delete-dir-on-start -C jsc.minify.mangle=false --out-dir denoTestsDist && node ../../scripts/fixDenoTestExtension.js && deno test -A --import-map ../../denoImportMap.json denoTestsDist",
|
|
25
|
+
"test:deno-unit": "swc tests --strip-leading-paths --delete-dir-on-start -C jsc.minify.mangle=false --out-dir denoTestsDist && node ../../scripts/fixDenoTestExtension.js && deno test -A --import-map ../../denoImportMap.json denoTestsDist",
|
|
26
|
+
"test:bun-unit": "node ../../scripts/fixBunTestExtension.js && bun test bunTestsDist",
|
|
21
27
|
"test:unit:watch": "mocha --no-warnings --watch --parallel 'tests/**/*.spec.ts'",
|
|
22
28
|
"test:type": "tsc --noEmit",
|
|
23
|
-
"test:test-type": "tsc --project tsconfig.
|
|
29
|
+
"test:test-type": "tsc --project tests/tsconfig.json"
|
|
24
30
|
},
|
|
25
31
|
"dependencies": {
|
|
26
|
-
"@discordeno/types": "19.0.0-next.
|
|
27
|
-
"tweetnacl": "^1.0.3"
|
|
32
|
+
"@discordeno/types": "19.0.0-next.f9bdfce"
|
|
28
33
|
},
|
|
29
34
|
"devDependencies": {
|
|
30
|
-
"@swc/cli": "^0.
|
|
31
|
-
"@swc/core": "^1.
|
|
32
|
-
"@types/chai": "^4.3.
|
|
33
|
-
"@types/mocha": "^10.0.
|
|
34
|
-
"@types/node": "^
|
|
35
|
-
"@types/sinon": "^
|
|
36
|
-
"c8": "^
|
|
37
|
-
"chai": "^
|
|
38
|
-
"eslint": "^8.
|
|
35
|
+
"@swc/cli": "^0.3.9",
|
|
36
|
+
"@swc/core": "^1.4.2",
|
|
37
|
+
"@types/chai": "^4.3.16",
|
|
38
|
+
"@types/mocha": "^10.0.7",
|
|
39
|
+
"@types/node": "^20.14.10",
|
|
40
|
+
"@types/sinon": "^17.0.3",
|
|
41
|
+
"c8": "^9.1.0",
|
|
42
|
+
"chai": "^5.1.1",
|
|
43
|
+
"eslint": "^8.57.0",
|
|
39
44
|
"eslint-config-discordeno": "*",
|
|
40
|
-
"mocha": "^10.
|
|
41
|
-
"sinon": "^
|
|
42
|
-
"ts-node": "^10.9.
|
|
45
|
+
"mocha": "^10.5.1",
|
|
46
|
+
"sinon": "^18.0.0",
|
|
47
|
+
"ts-node": "^10.9.2",
|
|
43
48
|
"tsconfig": "*",
|
|
44
|
-
"typescript": "^
|
|
49
|
+
"typescript": "^5.5.3"
|
|
45
50
|
}
|
|
46
51
|
}
|
package/dist/Collection.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Collection.d.ts","sourceRoot":"","sources":["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AAG,EAAE,KAAK,OAAO,CAAA;IACrD,mDAAmD;IACnD,QAAQ,EAAE,MAAM,CAAA;IAChB,4BAA4B;IAC5B,GAAG,CAAC,EAAE,cAAc,CAAA;CACrB"}
|
package/dist/Collection.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
2
|
-
export class Collection extends Map {
|
|
3
|
-
constructor(entries, options){
|
|
4
|
-
super(entries ?? []);
|
|
5
|
-
this.maxSize = options?.maxSize;
|
|
6
|
-
if (!options?.sweeper) return;
|
|
7
|
-
this.startSweeper(options.sweeper);
|
|
8
|
-
}
|
|
9
|
-
startSweeper(options) {
|
|
10
|
-
if (this.sweeper?.intervalId) clearInterval(this.sweeper.intervalId);
|
|
11
|
-
this.sweeper = options;
|
|
12
|
-
this.sweeper.intervalId = setInterval(()=>{
|
|
13
|
-
this.forEach((value, key)=>{
|
|
14
|
-
if (!this.sweeper?.filter(value, key, options.bot)) return;
|
|
15
|
-
this.delete(key);
|
|
16
|
-
return key;
|
|
17
|
-
});
|
|
18
|
-
}, options.interval);
|
|
19
|
-
return this.sweeper.intervalId;
|
|
20
|
-
}
|
|
21
|
-
stopSweeper() {
|
|
22
|
-
return clearInterval(this.sweeper?.intervalId);
|
|
23
|
-
}
|
|
24
|
-
changeSweeperInterval(newInterval) {
|
|
25
|
-
if (this.sweeper == null) return;
|
|
26
|
-
this.startSweeper({
|
|
27
|
-
filter: this.sweeper.filter,
|
|
28
|
-
interval: newInterval
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
changeSweeperFilter(newFilter) {
|
|
32
|
-
if (this.sweeper == null) return;
|
|
33
|
-
this.startSweeper({
|
|
34
|
-
filter: newFilter,
|
|
35
|
-
interval: this.sweeper.interval
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
/** Add an item to the collection. Makes sure not to go above the maxSize. */ set(key, value) {
|
|
39
|
-
// When this collection is maxSized make sure we can add first
|
|
40
|
-
if ((this.maxSize !== undefined || this.maxSize === 0) && this.size >= this.maxSize) {
|
|
41
|
-
return this;
|
|
42
|
-
}
|
|
43
|
-
return super.set(key, value);
|
|
44
|
-
}
|
|
45
|
-
/** Add an item to the collection, no matter what the maxSize is. */ forceSet(key, value) {
|
|
46
|
-
return super.set(key, value);
|
|
47
|
-
}
|
|
48
|
-
/** Convert the collection to an array. */ array() {
|
|
49
|
-
return [
|
|
50
|
-
...this.values()
|
|
51
|
-
];
|
|
52
|
-
}
|
|
53
|
-
/** Retrieve the value of the first element in this collection. */ first() {
|
|
54
|
-
return this.values().next().value;
|
|
55
|
-
}
|
|
56
|
-
/** Retrieve the value of the last element in this collection. */ last() {
|
|
57
|
-
return [
|
|
58
|
-
...this.values()
|
|
59
|
-
][this.size - 1];
|
|
60
|
-
}
|
|
61
|
-
/** Retrieve the value of a random element in this collection. */ random() {
|
|
62
|
-
const array = [
|
|
63
|
-
...this.values()
|
|
64
|
-
];
|
|
65
|
-
return array[Math.floor(Math.random() * array.length)];
|
|
66
|
-
}
|
|
67
|
-
/** Find a specific element in this collection. */ find(callback) {
|
|
68
|
-
for (const key of this.keys()){
|
|
69
|
-
const value = this.get(key);
|
|
70
|
-
if (callback(value, key)) return value;
|
|
71
|
-
}
|
|
72
|
-
// If nothing matched
|
|
73
|
-
}
|
|
74
|
-
/** Find all elements in this collection that match the given pattern. */ filter(callback) {
|
|
75
|
-
const relevant = new Collection();
|
|
76
|
-
this.forEach((value, key)=>{
|
|
77
|
-
if (callback(value, key)) relevant.set(key, value);
|
|
78
|
-
});
|
|
79
|
-
return relevant;
|
|
80
|
-
}
|
|
81
|
-
/** Converts the collection into an array by running a callback on all items in the collection. */ map(callback) {
|
|
82
|
-
const results = [];
|
|
83
|
-
for (const key of this.keys()){
|
|
84
|
-
const value = this.get(key);
|
|
85
|
-
results.push(callback(value, key));
|
|
86
|
-
}
|
|
87
|
-
return results;
|
|
88
|
-
}
|
|
89
|
-
/** Check if one of the items in the collection matches the pattern. */ some(callback) {
|
|
90
|
-
for (const key of this.keys()){
|
|
91
|
-
const value = this.get(key);
|
|
92
|
-
if (callback(value, key)) return true;
|
|
93
|
-
}
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
/** Check if all of the items in the collection matches the pattern. */ every(callback) {
|
|
97
|
-
for (const key of this.keys()){
|
|
98
|
-
const value = this.get(key);
|
|
99
|
-
if (!callback(value, key)) return false;
|
|
100
|
-
}
|
|
101
|
-
return true;
|
|
102
|
-
}
|
|
103
|
-
/** Runs a callback on all items in the collection, merging them into a single value. */ reduce(callback, initialValue) {
|
|
104
|
-
let accumulator = initialValue;
|
|
105
|
-
for (const key of this.keys()){
|
|
106
|
-
const value = this.get(key);
|
|
107
|
-
accumulator = callback(accumulator, value, key);
|
|
108
|
-
}
|
|
109
|
-
return accumulator;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
//# sourceMappingURL=Collection.js.map
|