Remedy.CDN (Remedy v0.6.8) View Source

Discord CDN interface.

Storing images and other assets can be painful, use this module to retreive assets from the discord cdn rather than storing them.

Each function takes the required parameters to directly access a resource.

Format

All images are returned as either a .png or a .gif if the asset is animated. This is done automatically.

Size

Images can be requested of a size in [16, 32, 64, 128, 256, 512, 1024, 2048, 4096]. This is given as an optional final argument to any of the functions in this module. Arguments given will be rounded to the next largest, or the largest size if you try to go over.

Unless specified, discord will deliver the smallest size available. ( Potato )

Link to this section Summary

Types

A four digit integer assigned by discord to avoid duplicate usernames

The images hash.

The images size.

The snowflake id of the resource.

Functions

Returns the url for the applications icon.

Returns the url for a custom emoji.

Returns the url for the default avatar of a user.

Returns the url for a guilds banner.

Returns the url for a guilds discovery splash.

Returns the url for a guilds icon.

Returns the url for a guilds splash.

Returns a sticker banner url.

Returns the url for the users avatar.

Returns the url for a users banner.

Link to this section Types

Specs

discriminator() :: integer()

A four digit integer assigned by discord to avoid duplicate usernames

Specs

hash() :: binary()

The images hash.

Specs

size() :: integer() | nil

The images size.

Specs

snowflake() :: Sunbake.Snowflake.t()

The snowflake id of the resource.

Specs

uri() :: String.t()

Link to this section Functions

Link to this function

achievement_icon(application_id, achievement_id, icon_hash, size \\ nil)

View Source

Specs

achievement_icon(snowflake(), snowflake(), hash(), size()) :: uri()

Returns an achievement icon url.

Link to this function

application_asset(application_id, asset_id, size \\ nil)

View Source

Specs

application_asset(snowflake(), hash(), size()) :: uri()

Returns an application asset url.

Link to this function

application_cover(application_id, cover_image, size \\ nil)

View Source

Specs

application_cover(snowflake(), hash(), size()) :: uri()

Returns an application cover url.

Link to this function

application_icon(application_id, icon, size \\ nil)

View Source

Specs

application_icon(snowflake(), hash(), size()) :: uri()

Returns the url for the applications icon.

Link to this function

custom_emoji(id, size \\ nil)

View Source

Specs

custom_emoji(snowflake(), size()) :: binary()

Returns the url for a custom emoji.

Link to this function

default_user_avatar(discriminator, size \\ nil)

View Source

Specs

default_user_avatar(discriminator(), size()) :: uri()

Returns the url for the default avatar of a user.

That is, their avatar if they do not have one set, based on their discriminator. It can also take just the discriminator if you wish to do so.

Examples

iex> Remedy.CDN.default_user_avatar(3)
"https://cdn.discordapp.com/embed/avatars/3.png"
Link to this function

guild_banner(guild_id, guild_banner, size)

View Source

Specs

guild_banner(snowflake(), hash(), size()) :: uri()

Returns the url for a guilds banner.

Link to this function

guild_discovery_splash(guild_id, guild_discovery_splash, size \\ nil)

View Source

Specs

guild_discovery_splash(snowflake(), hash(), size()) :: uri()

Returns the url for a guilds discovery splash.

Link to this function

guild_icon(id, guild_icon, size \\ nil)

View Source

Specs

guild_icon(snowflake(), hash(), size()) :: uri()

Returns the url for a guilds icon.

Examples

iex> Remedy.CDN.guild_icon(872417560094732328, "f817c5adaf96672c94a17de8e944f427")
"https://cdn.discordapp.com/icons/872417560094732328/f817c5adaf96672c94a17de8e944f427.png"
Link to this function

guild_splash(id, splash, size \\ nil)

View Source

Specs

guild_splash(snowflake(), hash(), size()) :: uri()

Returns the url for a guilds splash.

Examples

iex> Remedy.CDN.guild_splash(848619361782726696, "7ed6ea26b7a5e64f78ca5df202cf4d13")
"https://cdn.discordapp.com/splashes/848619361782726696/7ed6ea26b7a5e64f78ca5df202cf4d13.png"
Link to this function

sticker_pack_banner(banner_asset_id, size)

View Source

Specs

sticker_pack_banner(snowflake(), size()) :: uri()

Returns a sticker banner url.

Link to this function

user_avatar(id, user_avatar, size \\ nil)

View Source

Specs

user_avatar(snowflake(), hash(), size()) :: uri()

Returns the url for the users avatar.

Examples

iex> Remedy.CDN.user_avatar(707047919332884520, "1df05ae0f21a24c377e9a1051c2b6035", 128)
"https://cdn.discordapp.com/avatars/707047919332884520/1df05ae0f21a24c377e9a1051c2b6035.png?size=128"
Link to this function

user_banner(user_id, user_banner, size \\ nil)

View Source

Specs

user_banner(snowflake(), hash(), size()) :: uri()

Returns the url for a users banner.

Examples

iex> Remedy.CDN.user_banner(179255727561375744, "e625e858e48602248a69bcfdfa886ab4")
"https://cdn.discordapp.com/banners/179255727561375744/e625e858e48602248a69bcfdfa886ab4.png"