Class Formatter
Contains markdown formatting helpers.
Inheritance
Namespace: DSharpPlus
Assembly: cs.temp.dll.dll
Syntax
public static class Formatter
Methods
AttachedImageUrl(String)
Creates a url for using attachments in embeds. This can only be used as an Image URL, Thumbnail URL, Author icon URL or Footer icon URL.
Declaration
public static string AttachedImageUrl(string filename)
Parameters
Type | Name | Description |
---|---|---|
System.String | filename | Name of attached image to display |
Returns
Type | Description |
---|---|
System.String |
BlockCode(String, String)
Creates a block of code.
Declaration
public static string BlockCode(string content, string language = "")
Parameters
Type | Name | Description |
---|---|---|
System.String | content | Contents of the block. |
System.String | language | Language to use for highlighting. |
Returns
Type | Description |
---|---|
System.String | Formatted block of code. |
Bold(String)
Creates bold text.
Declaration
public static string Bold(string content)
Parameters
Type | Name | Description |
---|---|---|
System.String | content | Text to bolden. |
Returns
Type | Description |
---|---|
System.String | Formatted text. |
EmbedlessUrl(Uri)
Creates a URL that won't create a link preview.
Declaration
public static string EmbedlessUrl(Uri url)
Parameters
Type | Name | Description |
---|---|---|
Uri | url | Url to prevent from being previewed. |
Returns
Type | Description |
---|---|
System.String | Formatted url. |
Emoji(DiscordEmoji)
Creates a custom emoji string.
Declaration
public static string Emoji(DiscordEmoji emoji)
Parameters
Type | Name | Description |
---|---|---|
DiscordEmoji | emoji | Emoji to display. |
Returns
Type | Description |
---|---|
System.String | Formatted emoji. |
InlineCode(String)
Creates inline code snippet.
Declaration
public static string InlineCode(string content)
Parameters
Type | Name | Description |
---|---|---|
System.String | content | Contents of the snippet. |
Returns
Type | Description |
---|---|
System.String | Formatted inline code snippet. |
Italic(String)
Creates italicized text.
Declaration
public static string Italic(string content)
Parameters
Type | Name | Description |
---|---|---|
System.String | content | Text to italicize. |
Returns
Type | Description |
---|---|
System.String | Formatted text. |
MaskedUrl(String, Uri, String)
Creates a masked link. This link will display as specified text, and alternatively provided alt text. This can only be used in embeds.
Declaration
public static string MaskedUrl(string text, Uri url, string alt_text = "")
Parameters
Type | Name | Description |
---|---|---|
System.String | text | Text to display the link as. |
Uri | url | Url that the link will lead to. |
System.String | alt_text | Alt text to display on hover. |
Returns
Type | Description |
---|---|
System.String | Formatted url. |
Mention(DiscordChannel)
Creates a mention for specified channel.
Declaration
public static string Mention(DiscordChannel channel)
Parameters
Type | Name | Description |
---|---|---|
DiscordChannel | channel | Channel to mention. |
Returns
Type | Description |
---|---|
System.String | Formatted mention. |
Mention(DiscordRole)
Creates a mention for specified role.
Declaration
public static string Mention(DiscordRole role)
Parameters
Type | Name | Description |
---|---|---|
DiscordRole | role | Role to mention. |
Returns
Type | Description |
---|---|
System.String | Formatted mention. |
Mention(DiscordUser, Boolean)
Creates a mention for specified user or member. Can optionally specify to resolve nicknames.
Declaration
public static string Mention(DiscordUser user, bool nickname = false)
Parameters
Type | Name | Description |
---|---|---|
DiscordUser | user | User to create mention for. |
System.Boolean | nickname | Whether the mention should resovle nicknames or not. |
Returns
Type | Description |
---|---|
System.String | Formatted mention. |
Sanitize(String)
Escapes all markdown formatting from specified text.
Declaration
public static string Sanitize(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | Text to sanitize. |
Returns
Type | Description |
---|---|
System.String | Sanitized text. |
Spoiler(String)
Creates spoiler from text.
Declaration
public static string Spoiler(string content)
Parameters
Type | Name | Description |
---|---|---|
System.String | content | Text to spoilerize. |
Returns
Type | Description |
---|---|
System.String | Formatted text. |
Strike(String)
Creates strikethrough text.
Declaration
public static string Strike(string content)
Parameters
Type | Name | Description |
---|---|---|
System.String | content | Text to strikethrough. |
Returns
Type | Description |
---|---|
System.String | Formatted text. |
Strip(String)
Removes all markdown formatting from specified text.
Declaration
public static string Strip(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | Text to strip of formatting. |
Returns
Type | Description |
---|---|
System.String | Formatting-stripped text. |
Underline(String)
Creates underlined text.
Declaration
public static string Underline(string content)
Parameters
Type | Name | Description |
---|---|---|
System.String | content | Text to underline. |
Returns
Type | Description |
---|---|
System.String | Formatted text. |