1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-04-20 00:43:36 +03:00

/about: Show link to GitHub profile if Discord member wasn't found

Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
This commit is contained in:
Macintxsh 2023-12-18 05:36:05 +03:00
parent d4ea62d419
commit 25dadf8894
Signed by: mctaylors
GPG key ID: 7181BEBE676903C1
2 changed files with 16 additions and 1 deletions

View file

@ -88,7 +88,9 @@ public class AboutCommandGroup : CommandGroup
{ {
var guildMemberResult = await _guildApi.GetGuildMemberAsync( var guildMemberResult = await _guildApi.GetGuildMemberAsync(
guildId, dev.Id, ct); 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()}"); builder.AppendBulletPointLine($"{tag} — {$"AboutDeveloper@{dev.Username}".Localized()}");
} }

View file

@ -13,4 +13,17 @@ public static class MarkdownExtensions
{ {
return $"- {text}"; return $"- {text}";
} }
/// <summary>
/// Formats a string to use Markdown URL 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 string with URL.
/// </returns>
public static string Url(string text, string url)
{
return $"[{text}]({url})";
}
} }