Skip to content

Commit

Permalink
Added Header and Subtext to the Format class (#3052)
Browse files Browse the repository at this point in the history
  • Loading branch information
BlyZeDev authored Jan 14, 2025
1 parent b5f5df0 commit 0174745
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Discord.Net.Core/Format.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Text;
using System.Text.RegularExpressions;

Expand All @@ -24,11 +25,16 @@ public static class Format
public static string Url(string text, string url) => $"[{text}]({url})";
/// <summary> Escapes a URL so that a preview is not generated. </summary>
public static string EscapeUrl(string url) => $"<{url}>";
/// <summary> Returns a markdown-formatted string with header formatting. </summary>
public static string Header(string text, int level = 1)
=> level < 1 || level > 3 ? text : $"{new string('#', level)} {text}";
/// <summary> Returns a markdown-formatted string with subtext formatting. </summary>
public static string Subtext(string text) => $"-# {text}";

/// <summary> Returns a markdown-formatted string with codeblock formatting. </summary>
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}`";
Expand Down

0 comments on commit 0174745

Please sign in to comment.