From 25dadf8894ee50835390d63aeaef03ec8a69d7cc Mon Sep 17 00:00:00 2001 From: mctaylors Date: Mon, 18 Dec 2023 05:36:05 +0300 Subject: [PATCH] /about: Show link to GitHub profile if Discord member wasn't found Signed-off-by: mctaylors --- src/Commands/AboutCommandGroup.cs | 4 +++- src/Extensions/MarkdownExtensions.cs | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Commands/AboutCommandGroup.cs b/src/Commands/AboutCommandGroup.cs index 2c1e770..f52eed6 100644 --- a/src/Commands/AboutCommandGroup.cs +++ b/src/Commands/AboutCommandGroup.cs @@ -88,7 +88,9 @@ public class AboutCommandGroup : CommandGroup { var guildMemberResult = await _guildApi.GetGuildMemberAsync( guildId, dev.Id, ct); - var tag = guildMemberResult.IsSuccess ? $"<@{dev.Id}>" : $"@{dev.Username}"; + var tag = guildMemberResult.IsSuccess + ? $"<@{dev.Id}>" + : MarkdownExtensions.Url($"@{dev.Username}", $"https://github.com/{dev.Username}"); builder.AppendBulletPointLine($"{tag} — {$"AboutDeveloper@{dev.Username}".Localized()}"); } diff --git a/src/Extensions/MarkdownExtensions.cs b/src/Extensions/MarkdownExtensions.cs index 7b7f780..4fd415c 100644 --- a/src/Extensions/MarkdownExtensions.cs +++ b/src/Extensions/MarkdownExtensions.cs @@ -13,4 +13,17 @@ public static class MarkdownExtensions { return $"- {text}"; } + + /// + /// Formats a string to use Markdown URL formatting. + /// + /// The input text to format. + /// The URL to use in formatting. + /// + /// A markdown-formatted string with URL. + /// + public static string Url(string text, string url) + { + return $"[{text}]({url})"; + } }