mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 01:38:27 -04:00
Added .showembed <msgid> and .showembed #channel <msgid> which will show you embed json from the specified message
This commit is contained in:
@@ -8,6 +8,7 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
|
|||||||
- `.remindl` and `.remindrm` commands now supports optional 'server' parameter for Administrators which allows them to delete any reminder created on the server
|
- `.remindl` and `.remindrm` commands now supports optional 'server' parameter for Administrators which allows them to delete any reminder created on the server
|
||||||
- Added slots.currencyFontColor to gambling.yml
|
- Added slots.currencyFontColor to gambling.yml
|
||||||
- Added `.qexport` and `.qimport` commands which allow you to export and import quotes just like `.crsexport`
|
- Added `.qexport` and `.qimport` commands which allow you to export and import quotes just like `.crsexport`
|
||||||
|
- Added `.showembed <msgid>` and `.showembed #channel <msgid>` which will show you embed json from the specified message
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- `.at` and `.atl` commands reworked
|
- `.at` and `.atl` commands reworked
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using Discord;
|
using Discord;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Services;
|
using NadekoBot.Services;
|
||||||
@@ -29,6 +30,47 @@ namespace NadekoBot
|
|||||||
(Footer != null && (!string.IsNullOrWhiteSpace(Footer.Text) || !string.IsNullOrWhiteSpace(Footer.IconUrl))) ||
|
(Footer != null && (!string.IsNullOrWhiteSpace(Footer.Text) || !string.IsNullOrWhiteSpace(Footer.IconUrl))) ||
|
||||||
(Fields != null && Fields.Length > 0);
|
(Fields != null && Fields.Length > 0);
|
||||||
|
|
||||||
|
public static SmartEmbedText FromEmbed(IEmbed eb, string plainText = null)
|
||||||
|
{
|
||||||
|
var set = new SmartEmbedText();
|
||||||
|
|
||||||
|
set.PlainText = plainText;
|
||||||
|
set.Title = eb.Title;
|
||||||
|
set.Description = eb.Description;
|
||||||
|
set.Url = eb.Url;
|
||||||
|
set.Thumbnail = eb.Thumbnail?.Url;
|
||||||
|
set.Image = eb.Image?.Url;
|
||||||
|
set.Author = eb.Author is EmbedAuthor ea
|
||||||
|
? new()
|
||||||
|
{
|
||||||
|
Name = ea.Name,
|
||||||
|
Url = ea.Url,
|
||||||
|
IconUrl = ea.IconUrl
|
||||||
|
}
|
||||||
|
: null;
|
||||||
|
set.Footer = eb.Footer is EmbedFooter ef
|
||||||
|
? new()
|
||||||
|
{
|
||||||
|
Text = ef.Text,
|
||||||
|
IconUrl = ef.IconUrl
|
||||||
|
}
|
||||||
|
: null;
|
||||||
|
|
||||||
|
if (eb.Fields.Length > 0)
|
||||||
|
set.Fields = eb
|
||||||
|
.Fields
|
||||||
|
.Select(field => new SmartTextEmbedField()
|
||||||
|
{
|
||||||
|
Inline = field.Inline,
|
||||||
|
Name = field.Name,
|
||||||
|
Value = field.Value,
|
||||||
|
})
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
set.Color = eb.Color?.RawValue ?? 0;
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
|
||||||
public EmbedBuilder GetEmbed()
|
public EmbedBuilder GetEmbed()
|
||||||
{
|
{
|
||||||
var embed = new EmbedBuilder()
|
var embed = new EmbedBuilder()
|
||||||
|
@@ -363,6 +363,40 @@ namespace NadekoBot.Modules.Utility
|
|||||||
await ctx.Channel.EmbedAsync(embed);
|
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]
|
[NadekoCommand, Aliases]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
@@ -433,6 +467,8 @@ namespace NadekoBot.Modules.Utility
|
|||||||
New
|
New
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// [NadekoCommand, Usage, Description, Aliases]
|
// [NadekoCommand, Usage, Description, Aliases]
|
||||||
// [RequireContext(ContextType.Guild)]
|
// [RequireContext(ContextType.Guild)]
|
||||||
// public async Task CreateMyInvite(CreateInviteType type = CreateInviteType.Any)
|
// public async Task CreateMyInvite(CreateInviteType type = CreateInviteType.Any)
|
||||||
|
@@ -1271,3 +1271,5 @@ quotesexport:
|
|||||||
quotesimport:
|
quotesimport:
|
||||||
- quotesimport
|
- quotesimport
|
||||||
- qimport
|
- qimport
|
||||||
|
showembed:
|
||||||
|
- showembed
|
@@ -2153,3 +2153,8 @@ coordreload:
|
|||||||
desc: "Reloads coordinator config"
|
desc: "Reloads coordinator config"
|
||||||
args:
|
args:
|
||||||
- ""
|
- ""
|
||||||
|
showembed:
|
||||||
|
desc: "Prints the json equivalent of the embed of the message specified by its Id."
|
||||||
|
args:
|
||||||
|
- "820022733172121600"
|
||||||
|
- "#some-channel 820022733172121600"
|
Reference in New Issue
Block a user