module Discord::CDN

Overview

This module contains methods for building URLs to resources on Discord's CDN for things like guild icons and avatars.

NOTE All size arguments for CDN methods must be a power of 2 between 16 and 2048. If an invalid size is given, ArgumentError will be raised.

API Documentation for image formatting

Extended Modules

Defined in:

discordcr/cdn.cr

Constant Summary

BASE_URL = "https://cdn.discordapp.com"

Base CDN URL

Instance Method Summary

Instance Method Detail

def application_icon(id : UInt64 | Snowflake, icon : String, format : ApplicationIconFormat = ApplicationIconFormat::WebP, size : Int32 = 128) #

Produces a CDN URL for an application icon in the given format and size


[View source]
def custom_emoji(id : UInt64 | Snowflake, format : CustomEmojiFormat = CustomEmojiFormat::PNG, size : Int32 = 128) #

Produces a CDN URL for a custom emoji in the given format and size


[View source]
def default_user_avatar(user_discriminator : String) #

Produces a CDN URL for a default user avatar, calculated from the given discriminator value.


[View source]
def guild_icon(id : UInt64 | Snowflake, icon : String, format : GuildIconFormat = GuildIconFormat::WebP, size : Int32 = 128) #

Produces a CDN URL for a guild icon in the given format and size


[View source]
def guild_splash(id : UInt64 | Snowflake, splash : String, format : GuildSplashFormat = GuildSplashFormat::WebP, size : Int32 = 128) #

Produces a CDN URL for a guild splash in the given format and size


[View source]
def user_avatar(id : UInt64 | Snowflake, avatar : String, size : Int32 = 128) #

Produces a CDN URL for a user avatar in the given size. Given the avatar string, this will return a WebP or GIF based on the animated avatar hint.


[View source]
def user_avatar(id : UInt64 | Snowflake, avatar : String, format : UserAvatarFormat, size : Int32 = 128) #

Produces a CDN URL for a user avatar in the given format and size


[View source]