mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 01:38:27 -04:00
Added .roleinfo commands, added the ability to show colors other than ok error and pending to IEmbedBuilder
This commit is contained in:
@@ -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);
|
||||
|
@@ -98,6 +98,33 @@ public partial class Utility
|
||||
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)]
|
||||
public async Task UserInfo(IGuildUser usr = null)
|
||||
|
@@ -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();
|
||||
|
||||
|
@@ -217,6 +217,9 @@ serverinfo:
|
||||
channelinfo:
|
||||
- channelinfo
|
||||
- cinfo
|
||||
roleinfo:
|
||||
- roleinfo
|
||||
- rinfo
|
||||
userinfo:
|
||||
- userinfo
|
||||
- uinfo
|
||||
|
@@ -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:
|
||||
|
@@ -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.",
|
||||
|
Reference in New Issue
Block a user