Skip to content
This repository has been archived by the owner on Jan 8, 2022. It is now read-only.

Commit

Permalink
feat(CDN): add role icon endpoint (#64)
Browse files Browse the repository at this point in the history
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
  • Loading branch information
iShibi and vladfrangu authored Oct 2, 2021
1 parent c1a4658 commit 4d7d692
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/rest/__tests__/CDN.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ test('guildIcon dynamic-not-animated', () => {
expect(cdn.icon(id, hash, { dynamic: true })).toBe(`${base}/icons/${id}/${hash}.png`);
});

test('role icon default', () => {
expect(cdn.roleIcon(id, hash)).toBe(`${base}/role-icons/${id}/${hash}.png`);
});

test('splash default', () => {
expect(cdn.splash(id, hash)).toBe(`${base}/splashes/${id}/${hash}.png`);
});
Expand Down
10 changes: 10 additions & 0 deletions packages/rest/src/lib/CDN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ export class CDN {
return this.makeURL(`/icons/${guildId}/${iconHash}`, options);
}

/**
* Generates a URL for the icon of a role
* @param roleId The id of the role that has the icon
* @param roleIconHash The hash provided by Discord for this role icon
* @param options Optional options for the role icon
*/
public roleIcon(roleId: string, roleIconHash: string, options?: ImageURLOptions): string {
return this.makeURL(`/role-icons/${roleId}/${roleIconHash}`, options);
}

/**
* Generates a guild invite splash URL for a guild's invite splash.
* @param guildId The guild id that has the invite splash
Expand Down

0 comments on commit 4d7d692

Please sign in to comment.