From c0b43c6a184dcb118fccb2b5101afd3b63cc96a9 Mon Sep 17 00:00:00 2001 From: Macintxsh <95250141+mctaylors@users.noreply.github.com> Date: Mon, 18 Dec 2023 12:26:08 +0300 Subject: [PATCH] /about: Show link to GitHub profile if Discord member wasn't found (#226) In this PR, the behavior of the developer list display in /about has been changed. Now, if a developer is not on the same server where the /about command was executed, their username will have a link to their GitHub profile. --------- 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..a12c070 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.Hyperlink($"@{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..95cd344 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 Hyperlink formatting. + /// + /// The input text to format. + /// The URL to use in formatting. + /// + /// A markdown-formatted Hyperlink string. + /// + public static string Hyperlink(string text, string url) + { + return $"[{text}]({url})"; + } }