@chainfuse/helpers 0.6.0 → 0.7.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/dist/discord.d.mts +3 -1
- package/dist/discord.mjs +24 -1
- package/package.json +4 -4
package/dist/discord.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CustomLoging } from '@chainfuse/types';
|
|
2
2
|
import type { ExecutionContext } from '@cloudflare/workers-types/experimental';
|
|
3
|
-
import { REST, type RESTOptions } from '@discordjs/rest';
|
|
3
|
+
import { CDN, REST, type RESTOptions } from '@discordjs/rest';
|
|
4
4
|
export declare class DiscordHelpers {
|
|
5
5
|
/**
|
|
6
6
|
* Discord Epoch, the first second of 2015 or 1420070400000
|
|
@@ -18,4 +18,6 @@ export declare class DiscordHelpers {
|
|
|
18
18
|
*/
|
|
19
19
|
static discordSnowflakeToDate(snowflakeRaw?: bigint | string): Date;
|
|
20
20
|
static discordRest(apiKey: string, cacheTtl?: number, forceCache?: boolean, executionContext?: ExecutionContext, logger?: CustomLoging, restOptions?: Partial<Omit<RESTOptions, 'agent' | 'authPrefix' | 'makeRequest'>>): REST;
|
|
21
|
+
static userIcon(userId: bigint | string, userIconHash?: Parameters<CDN['avatar']>[1] | null, guildId?: bigint | string, memberIconHash?: Parameters<CDN['avatar']>[1] | null, options?: Parameters<CDN['avatar']>[2]): string;
|
|
22
|
+
static guildIcon(guildId: bigint | string, iconHash: Parameters<CDN['icon']>[1], options?: Parameters<CDN['icon']>[2]): string;
|
|
21
23
|
}
|
package/dist/discord.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { REST } from '@discordjs/rest';
|
|
1
|
+
import { CDN, REST } from '@discordjs/rest';
|
|
2
2
|
import { CryptoHelpers } from './crypto.mjs';
|
|
3
3
|
import { NetHelpers } from './net.mjs';
|
|
4
4
|
export class DiscordHelpers {
|
|
@@ -182,4 +182,27 @@ export class DiscordHelpers {
|
|
|
182
182
|
},
|
|
183
183
|
}).setToken(apiKey);
|
|
184
184
|
}
|
|
185
|
+
static userIcon(userId, userIconHash, guildId, memberIconHash, options) {
|
|
186
|
+
options = {
|
|
187
|
+
extension: (memberIconHash ?? userIconHash)?.startsWith('a_') ? 'gif' : 'png',
|
|
188
|
+
...options,
|
|
189
|
+
};
|
|
190
|
+
if (userIconHash) {
|
|
191
|
+
if (guildId && memberIconHash) {
|
|
192
|
+
return new CDN().guildMemberAvatar(BigInt(guildId).toString(), BigInt(userId).toString(), memberIconHash, options);
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
return new CDN().avatar(BigInt(userId).toString(), userIconHash, options);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
return new CDN().defaultAvatar(Number((BigInt(userId) >> BigInt(22)) % BigInt(6)));
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
static guildIcon(guildId, iconHash, options) {
|
|
203
|
+
return new CDN().icon(BigInt(guildId).toString(), iconHash, {
|
|
204
|
+
extension: iconHash.startsWith('a_') ? 'gif' : 'png',
|
|
205
|
+
...options,
|
|
206
|
+
});
|
|
207
|
+
}
|
|
185
208
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainfuse/helpers",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "ChainFuse",
|
|
6
6
|
"homepage": "https://github.com/ChainFuse/packages/tree/main/packages/helpers#readme",
|
|
@@ -51,11 +51,11 @@
|
|
|
51
51
|
"@discordjs/rest": "^2.4.2",
|
|
52
52
|
"chalk": "^5.4.1",
|
|
53
53
|
"cloudflare": "^3.5.0",
|
|
54
|
-
"uuid": "^11.0.
|
|
54
|
+
"uuid": "^11.0.5"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@chainfuse/types": "^1.4.
|
|
57
|
+
"@chainfuse/types": "^1.4.2",
|
|
58
58
|
"@types/node": "^22.10.5"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "abed5b9d3a63bfe419045c38f7e1402de09f11a6"
|
|
61
61
|
}
|