Added .roleinfo commands, added the ability to show colors other than ok error and pending to IEmbedBuilder

This commit is contained in:
Kwoth
2022-08-11 17:04:51 +02:00
parent dc229ea2b3
commit b164da38e3
6 changed files with 42 additions and 0 deletions

View File

@@ -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)]

View File

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

View File

@@ -217,6 +217,9 @@ serverinfo:
channelinfo:
- channelinfo
- cinfo
roleinfo:
- roleinfo
- rinfo
userinfo:
- userinfo
- uinfo

View File

@@ -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:

View File

@@ -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.",