Show / Hide Table of Contents

    Class Formatter

    Contains markdown formatting helpers.

    Inheritance
    Object
    Formatter
    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
    String filename

    Name of attached image to display

    Returns
    Type Description
    String

    BlockCode(String, String)

    Creates a block of code.

    Declaration
    public static string BlockCode(string content, string language = "")
    Parameters
    Type Name Description
    String content

    Contents of the block.

    String language

    Language to use for highlighting.

    Returns
    Type Description
    String

    Formatted block of code.

    Bold(String)

    Creates bold text.

    Declaration
    public static string Bold(string content)
    Parameters
    Type Name Description
    String content

    Text to bolden.

    Returns
    Type Description
    String

    Formatted text.

    Colorize(String, AnsiColor[])

    Colorizes text based using ANSI escape codes. Escape codes are only properly rendered in code blocks. Resets are inserted automatically.

    Declaration
    public static string Colorize(string text, params AnsiColor[] styles)
    Parameters
    Type Name Description
    String text

    The text to colorize.

    AnsiColor[] styles
    Returns
    Type Description
    String

    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
    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
    String

    Formatted emoji.

    InlineCode(String)

    Creates inline code snippet.

    Declaration
    public static string InlineCode(string content)
    Parameters
    Type Name Description
    String content

    Contents of the snippet.

    Returns
    Type Description
    String

    Formatted inline code snippet.

    Italic(String)

    Creates italicized text.

    Declaration
    public static string Italic(string content)
    Parameters
    Type Name Description
    String content

    Text to italicize.

    Returns
    Type Description
    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
    String text

    Text to display the link as.

    Uri url

    Url that the link will lead to.

    String alt_text

    Alt text to display on hover.

    Returns
    Type Description
    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
    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
    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.

    Boolean nickname

    Whether the mention should resolve nicknames or not.

    Returns
    Type Description
    String

    Formatted mention.

    Sanitize(String)

    Escapes all markdown formatting from specified text.

    Declaration
    public static string Sanitize(string text)
    Parameters
    Type Name Description
    String text

    Text to sanitize.

    Returns
    Type Description
    String

    Sanitized text.

    Spoiler(String)

    Creates spoiler from text.

    Declaration
    public static string Spoiler(string content)
    Parameters
    Type Name Description
    String content

    Text to spoilerize.

    Returns
    Type Description
    String

    Formatted text.

    Strike(String)

    Creates strikethrough text.

    Declaration
    public static string Strike(string content)
    Parameters
    Type Name Description
    String content

    Text to strikethrough.

    Returns
    Type Description
    String

    Formatted text.

    Strip(String)

    Removes all markdown formatting from specified text.

    Declaration
    public static string Strip(string text)
    Parameters
    Type Name Description
    String text

    Text to strip of formatting.

    Returns
    Type Description
    String

    Formatting-stripped text.

    Timestamp(DateTime, TimestampFormat)

    Creates a rendered timestamp.

    Declaration
    public static string Timestamp(DateTime time, TimestampFormat format = TimestampFormat.RelativeTime)
    Parameters
    Type Name Description
    DateTime time

    The time from now.

    TimestampFormat format

    The format to render the timestamp in. Defaults to relative.

    Returns
    Type Description
    String

    A formatted timestamp.

    Timestamp(DateTimeOffset, TimestampFormat)

    Creates a rendered timestamp.

    Declaration
    public static string Timestamp(DateTimeOffset time, TimestampFormat format = TimestampFormat.RelativeTime)
    Parameters
    Type Name Description
    DateTimeOffset time

    Timestamp to format.

    TimestampFormat format

    The format to render the timestamp in. Defaults to relative.

    Returns
    Type Description
    String

    A formatted timestamp.

    Timestamp(TimeSpan, TimestampFormat)

    Creates a rendered timestamp.

    Declaration
    public static string Timestamp(TimeSpan time, TimestampFormat format = TimestampFormat.RelativeTime)
    Parameters
    Type Name Description
    TimeSpan time

    The time from now.

    TimestampFormat format

    The format to render the timestamp in. Defaults to relative.

    Returns
    Type Description
    String

    A formatted timestamp.

    Underline(String)

    Creates underlined text.

    Declaration
    public static string Underline(string content)
    Parameters
    Type Name Description
    String content

    Text to underline.

    Returns
    Type Description
    String

    Formatted text.

    Back to top © 2016-2022 DSharpPlus Contributors