Table of Contents

Class ImageUrl

Namespace
NetCord
Assembly
NetCord.dll

Represents a URL to an image hosted by Discord.

public class ImageUrl : ISpanFormattable, IFormattable
Inheritance
ImageUrl
Implements
Inherited Members

Properties

SupportsSize

Indicates whether this ImageUrl supports a size query parameter.

public bool SupportsSize { get; }

Property Value

bool

Methods

AchievementIcon(ulong, ulong, string, ImageFormat)

Gets the ImageUrl of an achievement icon.

public static ImageUrl AchievementIcon(ulong applicationId, ulong achievementId, string iconHash, ImageFormat format)

Parameters

applicationId ulong

The ID of the application.

achievementId ulong

The ID of the achievement.

iconHash string

The achievement's icon hash.

format ImageFormat

The format of the returned ImageUrl.

Returns

ImageUrl

An ImageUrl pointing to the achievement icon.

ApplicationAsset(ulong, ulong, ImageFormat)

Gets the ImageUrl of an application asset.

public static ImageUrl ApplicationAsset(ulong applicationId, ulong assetId, ImageFormat format)

Parameters

applicationId ulong

The ID of the application.

assetId ulong

The ID of the asset.

format ImageFormat

The format of the returned ImageUrl.

Returns

ImageUrl

An ImageUrl pointing to the application asset.

ApplicationCover(ulong, string, ImageFormat)

Gets the ImageUrl of an application's cover image.

public static ImageUrl ApplicationCover(ulong applicationId, string coverHash, ImageFormat format)

Parameters

applicationId ulong

The ID of the application.

coverHash string

The application's cover image hash.

format ImageFormat

The format of the returned ImageUrl.

Returns

ImageUrl

An ImageUrl pointing to the application's cover image.

ApplicationIcon(ulong, string, ImageFormat)

Gets the ImageUrl of an application's icon.

public static ImageUrl ApplicationIcon(ulong applicationId, string iconHash, ImageFormat format)

Parameters

applicationId ulong

The ID of the application.

iconHash string

The application's icon hash.

format ImageFormat

The format of the returned ImageUrl.

Returns

ImageUrl

An ImageUrl pointing to the application's icon.

AvatarDecoration(string)

Gets the ImageUrl of an avatar decoration.

public static ImageUrl AvatarDecoration(string avatarDecorationHash)

Parameters

avatarDecorationHash string

The avatar decoration data asset hash.

Returns

ImageUrl

An ImageUrl pointing to the avatar decoration.

CustomEmoji(ulong, ImageFormat)

Gets the ImageUrl of a custom emoji.

public static ImageUrl CustomEmoji(ulong emojiId, ImageFormat format)

Parameters

emojiId ulong

The ID of the emoji.

format ImageFormat

The format of the returned ImageUrl.

Returns

ImageUrl

An ImageUrl pointing to the custom emoji.

DefaultUserAvatar(ushort)

Gets the ImageUrl of the default user avatar for users on the legacy username system.

public static ImageUrl DefaultUserAvatar(ushort discriminator)

Parameters

discriminator ushort

The user's discriminator.

Returns

ImageUrl

An ImageUrl pointing to the default user avatar.

Remarks

This ImageUrl does not support setting size.

DefaultUserAvatar(ulong)

Gets the ImageUrl of the default user avatar for users on the new username system.

public static ImageUrl DefaultUserAvatar(ulong id)

Parameters

id ulong

The user's ID.

Returns

ImageUrl

An ImageUrl pointing to the default user avatar.

Remarks

This ImageUrl does not support setting size.

GuildBanner(ulong, string, ImageFormat?)

Gets the ImageUrl of a guild's banner.

public static ImageUrl GuildBanner(ulong guildId, string bannerHash, ImageFormat? format)

Parameters

guildId ulong

The ID of the guild.

bannerHash string

The guild's banner hash.

format ImageFormat?

The format of the returned ImageUrl. Defaults to Png (or Gif for animated banners).

Returns

ImageUrl

An ImageUrl pointing to the guild's banner.

GuildDiscoverySplash(ulong, string, ImageFormat)

Gets the ImageUrl of a guild's discovery splash.

public static ImageUrl GuildDiscoverySplash(ulong guildId, string discoverySplashHash, ImageFormat format)

Parameters

guildId ulong

The ID of the guild.

discoverySplashHash string

The guild's discovery splash hash.

format ImageFormat

The format of the returned ImageUrl.

Returns

ImageUrl

An ImageUrl pointing to the guild's discovery splash.

GuildIcon(ulong, string, ImageFormat?)

Gets the ImageUrl of a guild's icon.

public static ImageUrl GuildIcon(ulong guildId, string iconHash, ImageFormat? format)

Parameters

guildId ulong

The ID of the guild.

iconHash string

The guild's icon hash.

format ImageFormat?

The format of the returned ImageUrl. Defaults to Png (or Gif for animated icons).

Returns

ImageUrl

An ImageUrl pointing to the guild's icon.

GuildScheduledEventCover(ulong, string, ImageFormat)

Gets the ImageUrl of a guild scheduled event's cover image.

public static ImageUrl GuildScheduledEventCover(ulong scheduledEventId, string coverImageHash, ImageFormat format)

Parameters

scheduledEventId ulong

The ID of the scheduled event.

coverImageHash string

The scheduled event's cover image hash.

format ImageFormat

The format of the returned ImageUrl.

Returns

ImageUrl

An ImageUrl pointing to the guild scheduled event's cover image.

GuildSplash(ulong, string, ImageFormat)

Gets the ImageUrl of a guild's splash.

public static ImageUrl GuildSplash(ulong guildId, string splashHash, ImageFormat format)

Parameters

guildId ulong

The ID of the guild.

splashHash string

The guild's splash hash.

format ImageFormat

The format of the returned ImageUrl.

Returns

ImageUrl

An ImageUrl pointing to the guild's splash.

GuildTagBadge(ulong, string, ImageFormat)

Gets the ImageUrl of a guild tag badge.

public static ImageUrl GuildTagBadge(ulong guildId, string badgeHash, ImageFormat format)

Parameters

guildId ulong

The ID of the guild.

badgeHash string

The guild tag badge hash.

format ImageFormat

The format of the returned ImageUrl.

Returns

ImageUrl

An ImageUrl pointing to the guild tag badge.

GuildUserAvatar(ulong, ulong, string, ImageFormat?)

Gets the ImageUrl of a guild user's avatar.

public static ImageUrl GuildUserAvatar(ulong guildId, ulong userId, string avatarHash, ImageFormat? format)

Parameters

guildId ulong

The ID of the guild.

userId ulong

The ID of the user.

avatarHash string

The user's avatar hash.

format ImageFormat?

The format of the returned ImageUrl. Defaults to Png (or Gif for animated avatars).

Returns

ImageUrl

An ImageUrl pointing to the guild user's avatar.

GuildUserBanner(ulong, ulong, string, ImageFormat?)

Gets the ImageUrl of a guild user's banner.

public static ImageUrl GuildUserBanner(ulong guildId, ulong userId, string bannerHash, ImageFormat? format)

Parameters

guildId ulong

The ID of the guild.

userId ulong

The ID of the user.

bannerHash string

The user's banner hash.

format ImageFormat?

The format of the returned ImageUrl. Defaults to Png (or Gif for animated banners).

Returns

ImageUrl

An ImageUrl pointing to the guild user's banner.

GuildWidget(ulong, GuildWidgetStyle?, string, ApiVersion?)

Gets the ImageUrl of a guild widget.

public static ImageUrl GuildWidget(ulong guildId, GuildWidgetStyle? style = null, string hostname = "discord.com", ApiVersion? version = null)

Parameters

guildId ulong

The ID of the guild.

style GuildWidgetStyle?

The style of the widget. If null, uses the default style.

hostname string

The hostname to use for the API request.

version ApiVersion?

The API version to use.

Returns

ImageUrl

An ImageUrl pointing to the guild widget.

Remarks

This ImageUrl does not support setting size.

RoleIcon(ulong, string, ImageFormat)

Gets the ImageUrl of a role's icon.

public static ImageUrl RoleIcon(ulong roleId, string iconHash, ImageFormat format)

Parameters

roleId ulong

The ID of the role.

iconHash string

The role's icon hash.

format ImageFormat

The format of the returned ImageUrl.

Returns

ImageUrl

An ImageUrl pointing to the role's icon.

Sticker(ulong, StickerFormat, ImageFormat)

Gets the ImageUrl of a sticker.

public static ImageUrl Sticker(ulong stickerId, StickerFormat stickerFormat, ImageFormat format)

Parameters

stickerId ulong

The ID of the sticker.

stickerFormat StickerFormat

The format of the sticker.

format ImageFormat

The format of the returned ImageUrl.

Returns

ImageUrl

An ImageUrl pointing to the sticker.

Remarks

This ImageUrl does not support setting size. Sticker GIFs use the media URL instead of the CDN URL.

StickerPackBanner(ulong, ImageFormat)

Gets the ImageUrl of a sticker pack banner.

public static ImageUrl StickerPackBanner(ulong stickerPackBannerAssetId, ImageFormat format)

Parameters

stickerPackBannerAssetId ulong

The ID of the sticker pack banner asset.

format ImageFormat

The format of the returned ImageUrl.

Returns

ImageUrl

An ImageUrl pointing to the sticker pack banner.

StorePageAsset(ulong, ulong, ImageFormat)

Gets the ImageUrl of a store page asset.

public static ImageUrl StorePageAsset(ulong applicationId, ulong assetId, ImageFormat format)

Parameters

applicationId ulong

The ID of the application.

assetId ulong

The ID of the asset.

format ImageFormat

The format of the returned ImageUrl.

Returns

ImageUrl

An ImageUrl pointing to the store page asset.

TeamIcon(ulong, string, ImageFormat)

Gets the ImageUrl of a team's icon.

public static ImageUrl TeamIcon(ulong teamId, string iconHash, ImageFormat format)

Parameters

teamId ulong

The ID of the team.

iconHash string

The team's icon hash.

format ImageFormat

The format of the returned ImageUrl.

Returns

ImageUrl

An ImageUrl pointing to the team's icon.

ToString()

public override string ToString()

Returns

string

ToString(int)

Returns the ImageUrl with a specified size.

public virtual string ToString(int size)

Parameters

size int

The desired size of the image. Can be any power of two between 16 and 4096.

Returns

string

A string representation of the ImageUrl with the specified size.

ToString(string?, IFormatProvider?)

Formats the value of the current ImageUrl using the specified format.

public string ToString(string? format, IFormatProvider? formatProvider)

Parameters

format string

The format to use. If null or empty, returns the URL without size parameter. Otherwise, should be a numeric string representing the desired size.

formatProvider IFormatProvider

The provider to use to format the value. This parameter is ignored.

Returns

string

A string representation of the ImageUrl.

TryFormat(Span<char>, out int, ReadOnlySpan<char>, IFormatProvider?)

Tries to format the value of the current ImageUrl into the provided span of characters.

public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = default, IFormatProvider? provider = null)

Parameters

destination Span<char>

The span in which to write the formatted value.

charsWritten int

When this method returns, contains the number of characters that were written in destination.

format ReadOnlySpan<char>

A span containing the format string. If empty, returns the URL without size parameter. Otherwise, should contain numeric characters representing the desired size.

provider IFormatProvider

The provider to use to format the value. This parameter is ignored.

Returns

bool

true if the formatting was successful; otherwise, false.

UserAvatar(ulong, string, ImageFormat?)

Gets the ImageUrl of a user's avatar.

public static ImageUrl UserAvatar(ulong userId, string avatarHash, ImageFormat? format)

Parameters

userId ulong

The ID of the user.

avatarHash string

The user's avatar hash.

format ImageFormat?

The format of the returned ImageUrl. Defaults to Png (or Gif for animated avatars).

Returns

ImageUrl

An ImageUrl pointing to the user's avatar.

UserBanner(ulong, string, ImageFormat?)

Gets the ImageUrl of a user's banner.

public static ImageUrl UserBanner(ulong userId, string bannerHash, ImageFormat? format)

Parameters

userId ulong

The ID of the user.

bannerHash string

The user's banner hash.

format ImageFormat?

The format of the returned ImageUrl. Defaults to Png (or Gif for animated banners).

Returns

ImageUrl

An ImageUrl pointing to the user's banner.