diff --git a/Discord.Addons.Interactive/InteractiveBase.cs b/Discord.Addons.Interactive/InteractiveBase.cs index c934f85..7170e64 100644 --- a/Discord.Addons.Interactive/InteractiveBase.cs +++ b/Discord.Addons.Interactive/InteractiveBase.cs @@ -23,7 +23,7 @@ public Task NextMessageAsync(bool fromSourceUser = true, bool inS public Task ReplyAndDeleteAsync(string content, bool isTTS = false, Embed embed = null, TimeSpan? timeout = null, RequestOptions options = null) => Interactive.ReplyAndDeleteAsync(Context, content, isTTS, embed, timeout, options); - public Task PagedReplyAsync(IEnumerable pages, bool fromSourceUser = true) + public Task PagedReplyAsync(IEnumerable pages, bool fromSourceUser = true) { var pager = new PaginatedMessage { diff --git a/Discord.Addons.Interactive/Paginator/PaginatedMessage.cs b/Discord.Addons.Interactive/Paginator/PaginatedMessage.cs index 569f40e..efd5b6e 100644 --- a/Discord.Addons.Interactive/Paginator/PaginatedMessage.cs +++ b/Discord.Addons.Interactive/Paginator/PaginatedMessage.cs @@ -4,7 +4,7 @@ namespace Discord.Addons.Interactive { public class PaginatedMessage { - public IEnumerable Pages { get; set; } + public IEnumerable Pages { get; set; } public string Content { get; set; } = ""; diff --git a/Discord.Addons.Interactive/Paginator/PaginatedMessageCallback.cs b/Discord.Addons.Interactive/Paginator/PaginatedMessageCallback.cs index 47b5e24..2f52057 100644 --- a/Discord.Addons.Interactive/Paginator/PaginatedMessageCallback.cs +++ b/Discord.Addons.Interactive/Paginator/PaginatedMessageCallback.cs @@ -132,13 +132,22 @@ public async Task HandleCallbackAsync(SocketReaction reaction) protected Embed BuildEmbed() { - return new EmbedBuilder() - .WithAuthor(_pager.Author) - .WithColor(_pager.Color) - .WithDescription(_pager.Pages.ElementAt(page-1).ToString()) + var p = _pager.Pages.ElementAt(page - 1); + + var embed = new EmbedBuilder() + .WithAuthor(p.Author ?? _pager.Author) + .WithColor(p.Color) + .WithDescription(p.Description ?? "null") .WithFooter(f => f.Text = string.Format(options.FooterFormat, page, pages)) - .WithTitle(_pager.Title) - .Build(); + .WithTitle(p.Title ?? _pager.Title); + + if (p.ImageUrl != null) + embed.WithImageUrl(p.ImageUrl); + + if (p.ThumbnailUrl != null) + embed.WithThumbnailUrl(p.ThumbnailUrl); + + return embed.Build(); } private async Task RenderAsync() { diff --git a/Discord.Addons.Interactive/Paginator/PaginatedMessageContent.cs b/Discord.Addons.Interactive/Paginator/PaginatedMessageContent.cs new file mode 100644 index 0000000..136a23e --- /dev/null +++ b/Discord.Addons.Interactive/Paginator/PaginatedMessageContent.cs @@ -0,0 +1,12 @@ +namespace Discord.Addons.Interactive +{ + public class PaginatedMessageContent + { + public string Title { get; set; } + public EmbedAuthorBuilder Author { get; set; } + public string Description { get; set; } + public string ImageUrl { get; set; } + public string ThumbnailUrl { get; set; } + public Color Color { get; set; } = Color.Default; + } +} diff --git a/SampleApp/Modules/SampleModule.cs b/SampleApp/Modules/SampleModule.cs index 4436e5b..cce08ba 100644 --- a/SampleApp/Modules/SampleModule.cs +++ b/SampleApp/Modules/SampleModule.cs @@ -37,7 +37,14 @@ public async Task Test_NextMessageAsync() [Command("paginator")] public async Task Test_Paginator() { - var pages = new[] { "Page 1", "Page 2", "Page 3", "aaaaaa", "Page 5" }; + var pages = new[] + { + new PaginatedMessageContent { Description = "Page 1" }, + new PaginatedMessageContent { Description = "Page 2" }, + new PaginatedMessageContent { Description = "Page 3" }, + new PaginatedMessageContent { Description = "aaaaaa" }, + new PaginatedMessageContent { Description = "Page 5"} + }; await PagedReplyAsync(pages); } }