forked from TeamInklings/Octobot
/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:
parent
96eed1a820
commit
c0b43c6a18
2 changed files with 16 additions and 1 deletions
|
@ -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()}");
|
||||
}
|
||||
|
|
|
@ -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})";
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue