1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-01-31 09:09:00 +03:00

/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 <cantsendmails@mctaylors.ru>
This commit is contained in:
Macintxsh 2023-12-18 12:26:08 +03:00 committed by GitHub
parent 96eed1a820
commit c0b43c6a18
Signed by: GitHub
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View file

@ -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()}");
}

View file

@ -13,4 +13,17 @@ public static class MarkdownExtensions
{
return $"- {text}";
}
/// <summary>
/// Formats a string to use Markdown Hyperlink formatting.
/// </summary>
/// <param name="text">The input text to format.</param>
/// <param name="url">The URL to use in formatting.</param>
/// <returns>
/// A markdown-formatted Hyperlink string.
/// </returns>
public static string Hyperlink(string text, string url)
{
return $"[{text}]({url})";
}
}