Added .showembed <msgid> and .showembed #channel <msgid> which will show you embed json from the specified message

This commit is contained in:
Kwoth
2021-12-13 20:29:45 +01:00
parent 96c9b699aa
commit 9be8140d4d
5 changed files with 88 additions and 2 deletions

View File

@@ -362,7 +362,41 @@ namespace NadekoBot.Modules.Utility
await ctx.Channel.EmbedAsync(embed);
}
[NadekoCommand, Aliases]
[RequireContext(ContextType.Guild)]
public Task ShowEmbed(ulong messageId)
=> ShowEmbed((ITextChannel)ctx.Channel, messageId);
[NadekoCommand, Aliases]
[RequireContext(ContextType.Guild)]
public async Task ShowEmbed(ITextChannel ch, ulong messageId)
{
var user = (IGuildUser)ctx.User;
var perms = user.GetPermissions(ch);
if (!perms.ReadMessageHistory || !perms.ViewChannel)
{
await ReplyErrorLocalizedAsync(strs.insuf_perms_u);
return;
}
var msg = await ch.GetMessageAsync(messageId);
if (msg is null)
{
await ReplyErrorLocalizedAsync(strs.msg_not_found);
return;
}
var embed = msg.Embeds.FirstOrDefault();
if (embed is null)
{
await ReplyErrorLocalizedAsync(strs.not_found);
return;
}
var json = SmartEmbedText.FromEmbed(embed, msg.Content).ToJson();
await SendConfirmAsync(Format.Sanitize(json).Replace("](", "]\\("));
}
[NadekoCommand, Aliases]
[RequireContext(ContextType.Guild)]
@@ -433,6 +467,8 @@ namespace NadekoBot.Modules.Utility
New
}
// [NadekoCommand, Usage, Description, Aliases]
// [RequireContext(ContextType.Guild)]
// public async Task CreateMyInvite(CreateInviteType type = CreateInviteType.Any)