mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
feat: support user guilds (#10962)
* feat: support user guilds * chore: add cdn test * chore: suggested changes * refactor: move to user primary guild to its own class * docs: update description of `badgeHash` parameter * chore: export UserPrimaryGuild * refactor: revert to no `UserPrimaryGuild` * fix: use key in data * fix: both `in` and is truthy check * docs: remove `-` Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> --------- Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
This commit is contained in:
@@ -134,8 +134,11 @@ test('soundboardSound', () => {
|
||||
expect(cdn.soundboardSound(id)).toEqual(`${baseCDN}/soundboard-sounds/${id}`);
|
||||
});
|
||||
|
||||
test('guildTagBadge', () => {
|
||||
expect(cdn.guildTagBadge(id, hash)).toEqual(`${baseCDN}/guild-tag-badges/${id}/${hash}.webp`);
|
||||
});
|
||||
|
||||
test('makeURL throws on invalid size', () => {
|
||||
// @ts-expect-error: Invalid size
|
||||
expect(() => cdn.avatar(id, animatedHash, { size: 5 })).toThrow(RangeError);
|
||||
});
|
||||
|
||||
|
||||
@@ -340,6 +340,17 @@ export class CDN {
|
||||
return `${this.cdn}${CDNRoutes.soundboardSound(soundId)}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a URL for a guild tag badge.
|
||||
*
|
||||
* @param guildId - The guild id
|
||||
* @param badgeHash - The hash of the badge
|
||||
* @param options - Optional options for the badge
|
||||
*/
|
||||
public guildTagBadge(guildId: string, badgeHash: string, options?: Readonly<BaseImageURLOptions>): string {
|
||||
return this.makeURL(`/guild-tag-badges/${guildId}/${badgeHash}`, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs the URL for the resource, checking whether or not `hash` starts with `a_` if `dynamic` is set to `true`.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user