diff --git a/locale/Messages.resx b/locale/Messages.resx index 71e80c9..1caa63a 100644 --- a/locale/Messages.resx +++ b/locale/Messages.resx @@ -636,4 +636,13 @@ Muted with a mute role + + Guild member since + + + Nickname + + + Roles + diff --git a/locale/Messages.ru.resx b/locale/Messages.ru.resx index 8cf9c8b..734b02a 100644 --- a/locale/Messages.ru.resx +++ b/locale/Messages.ru.resx @@ -636,4 +636,13 @@ Заглушен с помощью роли мута + + Участник сервера с + + + Никнейм + + + Роли + diff --git a/locale/Messages.tt-ru.resx b/locale/Messages.tt-ru.resx index eeda594..098775f 100644 --- a/locale/Messages.tt-ru.resx +++ b/locale/Messages.tt-ru.resx @@ -636,4 +636,13 @@ замучен ролькой + + участник сервера со времен + + + сервернейм + + + рольки + diff --git a/src/Commands/ToolsCommandGroup.cs b/src/Commands/ToolsCommandGroup.cs index 57161fb..d7d6785 100644 --- a/src/Commands/ToolsCommandGroup.cs +++ b/src/Commands/ToolsCommandGroup.cs @@ -42,7 +42,8 @@ public class ToolsCommandGroup : CommandGroup } /// - /// A slash command that shows general information about user & user's punishments. + /// A slash command that shows user's display name, joined Discord & joined server dates + /// and current punishments. /// /// The user to show info about. /// @@ -87,19 +88,21 @@ public class ToolsCommandGroup : CommandGroup if (user.GlobalName is not null) { builder.Append("- ").AppendLine(Messages.ShowInfoDisplayName) - .Append(" - ").AppendLine(Markdown.Sanitize(user.GlobalName)); + .AppendLine(Markdown.InlineCode(user.GlobalName)); } builder.Append("- ").AppendLine(Messages.ShowInfoDiscordUserSince) - .Append(" - ").AppendLine(Markdown.Timestamp(user.ID.Timestamp)); + .AppendLine(Markdown.Timestamp(user.ID.Timestamp)); var memberData = data.GetOrCreateMemberData(user.ID); var guildMemberResult = await _guildApi.GetGuildMemberAsync(guildId, user.ID, ct); DateTimeOffset? communicationDisabledUntil = null; - if (guildMemberResult.IsSuccess) + if (guildMemberResult.IsDefined(out var guildMember)) { - communicationDisabledUntil = guildMemberResult.Entity.CommunicationDisabledUntil.Value; + communicationDisabledUntil = guildMember.CommunicationDisabledUntil.Value; + + AppendGuildInformation(guildMember, builder); } var isMuted = (memberData.MutedUntil is not null && DateTimeOffset.UtcNow <= memberData.MutedUntil) || @@ -148,6 +151,29 @@ public class ToolsCommandGroup : CommandGroup return await _feedback.SendContextualEmbedResultAsync(embed, ct); } + private static void AppendGuildInformation(IGuildMember guildMember, StringBuilder builder) + { + if (guildMember.Nickname.Value is not null) + { + builder.Append("- ").AppendLine(Messages.ShowInfoGuildNickname) + .AppendLine(Markdown.InlineCode(guildMember.Nickname.Value)); + } + + builder.Append("- ").AppendLine(Messages.ShowInfoGuildMemberSince) + .AppendLine(Markdown.Timestamp(guildMember.JoinedAt)); + + if (guildMember.Roles.Count > 0) + { + builder.Append("- ").AppendLine(Messages.ShowInfoGuildRoles); + for (var i = 0; i < guildMember.Roles.Count - 1; i++) + { + builder.Append($"<@&{guildMember.Roles[i]}>, "); + } + + builder.Append($"<@&{guildMember.Roles[^1]}>"); + } + } + private static void AppendBanInformation(MemberData memberData, StringBuilder builder) { if (memberData.BannedUntil < DateTimeOffset.MaxValue) diff --git a/src/Messages.Designer.cs b/src/Messages.Designer.cs index 4d59769..8209b2c 100644 --- a/src/Messages.Designer.cs +++ b/src/Messages.Designer.cs @@ -1085,5 +1085,23 @@ namespace Boyfriend { return ResourceManager.GetString("ShowInfoMutedWithMuteRole", resourceCulture); } } + + internal static string ShowInfoGuildMemberSince { + get { + return ResourceManager.GetString("ShowInfoGuildMemberSince", resourceCulture); + } + } + + internal static string ShowInfoGuildNickname { + get { + return ResourceManager.GetString("ShowInfoGuildNickname", resourceCulture); + } + } + + internal static string ShowInfoGuildRoles { + get { + return ResourceManager.GetString("ShowInfoGuildRoles", resourceCulture); + } + } } }