Skip to main content

Cdn

Struct Cdn 

Source
pub struct Cdn { /* private fields */ }
Expand description

Builds CDN URLs (D-137). See the module documentation.

discord.js counterpart: CDN (@discordjs/rest).

Implementations§

Source§

impl Cdn

Source

pub fn new(cdn: impl Into<String>, media_proxy: impl Into<String>) -> Self

A CDN with other base URLs (e.g. a proxy). Trailing slashes are ignored.

discord.js counterpart: new CDN(cdn, mediaProxy) (@discordjs/rest).

Source

pub fn base(&self) -> &str

The CDN base URL.

discord.js counterpart: the cdn option of RESTOptions (@discordjs/rest).

Source

pub fn media_proxy(&self) -> &str

The media proxy base URL.

discord.js counterpart: the mediaProxy option of RESTOptions (@discordjs/rest).

Source

pub fn emoji( &self, emoji_id: EmojiId, animated: bool, options: ImageOptions, ) -> String

A custom emoji (PNG, JPEG, WebP, GIF). Emojis have no hash, so pass whether the emoji is animated. Discord recommends WebP for emojis.

discord.js counterpart: CDN#emoji.

Source

pub fn guild_icon( &self, guild_id: GuildId, hash: ImageHash, options: ImageOptions, ) -> String

A guild’s icon (PNG, JPEG, WebP, GIF).

discord.js counterpart: CDN#icon, Guild#iconURL.

Source

pub fn guild_splash( &self, guild_id: GuildId, hash: ImageHash, options: ImageOptions, ) -> String

A guild’s invite splash (PNG, JPEG, WebP).

discord.js counterpart: CDN#splash, Guild#splashURL.

Source

pub fn guild_discovery_splash( &self, guild_id: GuildId, hash: ImageHash, options: ImageOptions, ) -> String

A guild’s discovery splash (PNG, JPEG, WebP).

discord.js counterpart: CDN#discoverySplash, Guild#discoverySplashURL.

Source

pub fn guild_banner( &self, guild_id: GuildId, hash: ImageHash, options: ImageOptions, ) -> String

A guild’s banner (PNG, JPEG, WebP, GIF).

discord.js counterpart: CDN#banner, Guild#bannerURL.

Source

pub fn user_banner( &self, user_id: UserId, hash: ImageHash, options: ImageOptions, ) -> String

A user’s profile banner (PNG, JPEG, WebP, GIF).

discord.js counterpart: CDN#banner, User#bannerURL.

Source

pub fn default_user_avatar(&self, index: u8) -> String

The default avatar index (0-5, see default_avatar_index) of users without one (always PNG of a fixed size).

discord.js counterpart: CDN#defaultAvatar, User#defaultAvatarURL.

Source

pub fn user_avatar( &self, user_id: UserId, hash: ImageHash, options: ImageOptions, ) -> String

A user’s avatar (PNG, JPEG, WebP, GIF).

discord.js counterpart: CDN#avatar, User#avatarURL.

Source

pub fn guild_member_avatar( &self, guild_id: GuildId, user_id: UserId, hash: ImageHash, options: ImageOptions, ) -> String

A member’s guild-specific avatar (PNG, JPEG, WebP, GIF).

discord.js counterpart: CDN#guildMemberAvatar, GuildMember#avatarURL.

Source

pub fn guild_member_banner( &self, guild_id: GuildId, user_id: UserId, hash: ImageHash, options: ImageOptions, ) -> String

A member’s guild-specific banner (PNG, JPEG, WebP, GIF).

discord.js counterpart: CDN#guildMemberBanner, GuildMember#bannerURL.

Source

pub fn avatar_decoration(&self, asset: ImageHash) -> String

An avatar decoration, from its asset (always PNG).

discord.js counterpart: CDN#avatarDecoration, User#avatarDecorationURL.

Source

pub fn application_icon( &self, application_id: ApplicationId, hash: ImageHash, options: ImageOptions, ) -> String

An application’s icon (PNG, JPEG, WebP).

discord.js counterpart: CDN#appIcon, Application#iconURL.

Source

pub fn application_cover( &self, application_id: ApplicationId, hash: ImageHash, options: ImageOptions, ) -> String

An application’s default rich presence invite cover (PNG, JPEG, WebP).

discord.js counterpart: CDN#appIcon, Application#coverURL.

Source

pub fn application_asset( &self, application_id: ApplicationId, asset_id: &str, options: ImageOptions, ) -> String

An application’s rich presence asset, e.g. an activity’s large_image (PNG, JPEG, WebP).

discord.js counterpart: CDN#appAsset, RichPresenceAssets#largeImageURL.

Source

pub fn achievement_icon( &self, application_id: ApplicationId, achievement_id: GenericId, hash: ImageHash, options: ImageOptions, ) -> String

An achievement’s icon (PNG, JPEG, WebP).

discord.js counterpart: none.

Source

pub fn store_page_asset( &self, application_id: ApplicationId, asset_id: GenericId, options: ImageOptions, ) -> String

An asset of an application’s store page (PNG, JPEG, WebP).

discord.js counterpart: none.

Source

pub fn sticker_pack_banner( &self, banner_asset_id: GenericId, options: ImageOptions, ) -> String

A sticker pack’s banner, from its banner_asset_id (PNG, JPEG, WebP).

discord.js counterpart: CDN#stickerPackBanner, StickerPack#bannerURL.

Source

pub fn team_icon( &self, team_id: TeamId, hash: ImageHash, options: ImageOptions, ) -> String

A team’s icon (PNG, JPEG, WebP).

discord.js counterpart: CDN#teamIcon, Team#iconURL.

Source

pub fn sticker( &self, sticker_id: StickerId, format_type: StickerFormatType, ) -> String

A sticker, in the format its format_type is served in (fixed size): PNG for PNG and APNG stickers, Lottie JSON for Lottie ones, and GIF — from the media proxy — for GIF ones.

discord.js counterpart: CDN#sticker, Sticker#url.

Source

pub fn role_icon( &self, role_id: RoleId, hash: ImageHash, options: ImageOptions, ) -> String

A role’s icon (PNG, JPEG, WebP).

discord.js counterpart: CDN#roleIcon, Role#iconURL.

Source

pub fn guild_scheduled_event_cover( &self, event_id: ScheduledEventId, hash: ImageHash, options: ImageOptions, ) -> String

A scheduled event’s cover image (PNG, JPEG, WebP).

discord.js counterpart: CDN#guildScheduledEventCover, GuildScheduledEvent#coverImageURL.

Source

pub fn guild_tag_badge( &self, guild_id: GuildId, hash: ImageHash, options: ImageOptions, ) -> String

A guild’s server tag badge, from a user’s primary_guild (PNG, JPEG, WebP).

discord.js counterpart: CDN#guildTagBadge.

Source

pub fn channel_icon( &self, channel_id: ChannelId, hash: ImageHash, options: ImageOptions, ) -> String

A group DM’s icon (PNG, JPEG, WebP). Not in Discord’s table; the path discord.js uses.

discord.js counterpart: CDN#channelIcon, GroupDMChannel#iconURL.

Source

pub fn soundboard_sound(&self, sound_id: SoundboardSoundId) -> String

A soundboard sound’s audio file (no extension; Discord serves MP3 or Ogg).

discord.js counterpart: CDN#soundboardSound, SoundboardSound#url.

Trait Implementations§

Source§

impl Clone for Cdn

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Cdn

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Cdn

Source§

fn default() -> Self

Discord’s CDN and media proxy.

Source§

impl Eq for Cdn

Source§

impl PartialEq for Cdn

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Cdn

Auto Trait Implementations§

§

impl Freeze for Cdn

§

impl RefUnwindSafe for Cdn

§

impl Send for Cdn

§

impl Sync for Cdn

§

impl Unpin for Cdn

§

impl UnsafeUnpin for Cdn

§

impl UnwindSafe for Cdn

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more