diff --git a/src/Discord.Net.Core/Format.cs b/src/Discord.Net.Core/Format.cs index 04e811c7..6c8243fc 100644 --- a/src/Discord.Net.Core/Format.cs +++ b/src/Discord.Net.Core/Format.cs @@ -1,3 +1,4 @@ +using System; using System.Text; using System.Text.RegularExpressions; @@ -24,11 +25,16 @@ namespace Discord public static string Url(string text, string url) => $"[{text}]({url})"; /// Escapes a URL so that a preview is not generated. public static string EscapeUrl(string url) => $"<{url}>"; + /// Returns a markdown-formatted string with header formatting. + public static string Header(string text, int level = 1) + => level < 1 || level > 3 ? text : $"{new string('#', level)} {text}"; + /// Returns a markdown-formatted string with subtext formatting. + public static string Subtext(string text) => $"-# {text}"; /// Returns a markdown-formatted string with codeblock formatting. public static string Code(string text, string language = null) { - if (language != null || text.Contains("\n")) + if (language is not null || text.Contains("\n")) return $"```{language ?? ""}\n{text}\n```"; else return $"`{text}`";