diff --git a/src/Nadeko.Medusa/IEmbedBuilder.cs b/src/Nadeko.Medusa/IEmbedBuilder.cs index 001848967..d44936fc1 100644 --- a/src/Nadeko.Medusa/IEmbedBuilder.cs +++ b/src/Nadeko.Medusa/IEmbedBuilder.cs @@ -10,6 +10,7 @@ public interface IEmbedBuilder IEmbedBuilder WithFooter(string text, string? iconUrl = null); IEmbedBuilder WithAuthor(string name, string? iconUrl = null, string? url = null); IEmbedBuilder WithColor(EmbedColor color); + IEmbedBuilder WithDiscordColor(Color color); Embed Build(); IEmbedBuilder WithUrl(string url); IEmbedBuilder WithImageUrl(string url); diff --git a/src/NadekoBot/Modules/Utility/Info/InfoCommands.cs b/src/NadekoBot/Modules/Utility/Info/InfoCommands.cs index a2d740431..d93429e39 100644 --- a/src/NadekoBot/Modules/Utility/Info/InfoCommands.cs +++ b/src/NadekoBot/Modules/Utility/Info/InfoCommands.cs @@ -97,6 +97,33 @@ public partial class Utility .WithOkColor(); await ctx.Channel.EmbedAsync(embed); } + + [Cmd] + [RequireUserPermission(GuildPermission.ManageRoles)] + public async Task RoleInfo([Leftover] SocketRole role) + { + if (role.IsEveryone) + return; + + var createdAt = new DateTime(2015, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc) + .AddMilliseconds(role.Id >> 22); + var usercount = role.Members.LongCount(); + var embed = _eb.Create() + .WithTitle(role.Name.TrimTo(128)) + .WithDescription(role.Permissions.ToList().Join(" | ")) + .AddField(GetText(strs.id), role.Id.ToString(), true) + .AddField(GetText(strs.created_at), $"{createdAt:dd.MM.yyyy HH:mm}", true) + .AddField(GetText(strs.users), usercount.ToString(), true) + .AddField(GetText(strs.color), $"#{role.Color.R:X2}{role.Color.G:X2}{role.Color.B:X2}", true) + .AddField(GetText(strs.mentionable), role.IsMentionable.ToString(), true) + .AddField(GetText(strs.hoisted), role.IsHoisted.ToString(), true) + .WithOkColor(); + + if (!string.IsNullOrWhiteSpace(role.GetIconUrl())) + embed = embed.WithThumbnailUrl(role.GetIconUrl()); + + await ctx.Channel.EmbedAsync(embed); + } [Cmd] [RequireContext(ContextType.Guild)] diff --git a/src/NadekoBot/Services/IEmbedBuilderService.cs b/src/NadekoBot/Services/IEmbedBuilderService.cs index f345ff28a..1474a08f7 100644 --- a/src/NadekoBot/Services/IEmbedBuilderService.cs +++ b/src/NadekoBot/Services/IEmbedBuilderService.cs @@ -67,6 +67,9 @@ public sealed class DiscordEmbedBuilderWrapper : IEmbedBuilder _ => throw new ArgumentOutOfRangeException(nameof(color), "Unsupported EmbedColor type") }; + public IEmbedBuilder WithDiscordColor(Color color) + => Wrap(embed.WithColor(color)); + public Embed Build() => embed.Build(); diff --git a/src/NadekoBot/data/aliases.yml b/src/NadekoBot/data/aliases.yml index ffa8258aa..31c7c0cfa 100644 --- a/src/NadekoBot/data/aliases.yml +++ b/src/NadekoBot/data/aliases.yml @@ -217,6 +217,9 @@ serverinfo: channelinfo: - channelinfo - cinfo +roleinfo: + - roleinfo + - rinfo userinfo: - userinfo - uinfo diff --git a/src/NadekoBot/data/strings/commands/commands.en-US.yml b/src/NadekoBot/data/strings/commands/commands.en-US.yml index 4d5e51e80..5af8a850e 100644 --- a/src/NadekoBot/data/strings/commands/commands.en-US.yml +++ b/src/NadekoBot/data/strings/commands/commands.en-US.yml @@ -423,6 +423,10 @@ channelinfo: desc: "Shows info about the channel. If no channel is supplied, it defaults to current one." args: - "#some-channel" +roleinfo: + desc: "Shows info about the specified role." + args: + - "Gamers" userinfo: desc: "Shows info about the user. If no user is supplied, it defaults a user running the command." args: diff --git a/src/NadekoBot/data/strings/responses/responses.en-US.json b/src/NadekoBot/data/strings/responses/responses.en-US.json index 69557c7ac..fc540d718 100644 --- a/src/NadekoBot/data/strings/responses/responses.en-US.json +++ b/src/NadekoBot/data/strings/responses/responses.en-US.json @@ -142,6 +142,10 @@ "rar_err": "Failed to remove roles. I have insufficient permissions.", "rc": "Color of {0} role has been changed.", "rc_perms": "Error occurred due to invalid color or insufficient permissions.", + "color": "Color", + "icon": "Icon", + "hoisted": "Hoisted", + "mentionable": "Mentionable", "remrole": "Successfully removed role {0} from user {1}", "remrole_err": "Failed to remove role. I have insufficient permissions.", "renrole": "Role renamed.",