Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Discord.Addons.Interactive/InteractiveBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public Task<SocketMessage> NextMessageAsync(bool fromSourceUser = true, bool inS
public Task<IUserMessage> 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<IUserMessage> PagedReplyAsync(IEnumerable<object> pages, bool fromSourceUser = true)
public Task<IUserMessage> PagedReplyAsync(IEnumerable<PaginatedMessageContent> pages, bool fromSourceUser = true)
{
var pager = new PaginatedMessage
{
Expand Down
2 changes: 1 addition & 1 deletion Discord.Addons.Interactive/Paginator/PaginatedMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Discord.Addons.Interactive
{
public class PaginatedMessage
{
public IEnumerable<object> Pages { get; set; }
public IEnumerable<PaginatedMessageContent> Pages { get; set; }

public string Content { get; set; } = "";

Expand Down
21 changes: 15 additions & 6 deletions Discord.Addons.Interactive/Paginator/PaginatedMessageCallback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,22 @@ public async Task<bool> 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")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't default to a "null" if there isn't a description.

.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()
{
Expand Down
12 changes: 12 additions & 0 deletions Discord.Addons.Interactive/Paginator/PaginatedMessageContent.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
9 changes: 8 additions & 1 deletion SampleApp/Modules/SampleModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down