public async Task PagedMenuAsync() { var pages = new Page[] { /* string */ "First page!", /* embed */ new LocalEmbedBuilder().WithDescription("Second page!").Build(), /* tuple */ ("Third page!", new LocalEmbedBuilder().WithAuthor(Context.User).Build()) }; var pageProvider = new DefaultPageProvider(pages); var menu = new PagedMenu(Context.User.Id, pageProvider); await Context.Channel.StartMenuAsync(menu); }
public async Task ListRemindersAsync() { var reminders = ReminderService.GetRemindersForUser(Context.Member.Id) .Where(reminder => reminder.UserId == Context.Member.Id.RawValue && Context.Guild.Channels.ContainsKey(reminder.ChannelId)) .OrderBy(reminder => reminder.TriggerAt) .ToList(); switch (reminders.Count) { case 0: await ReplyAsync(NO_REMINDERS_FOUND); return; case <= BatchSize: var embed = await CreateReminderEmbedAsync(reminders); await ReplyAsync(embed : embed.Build()); return; } var numberOfPages = MathEx.CeilingDivision(reminders.Count, BatchSize); var reminderBatches = reminders.Batch(BatchSize); var pageIndex = 0; var reminderPages = new List <Page>(); foreach (var reminderBatch in reminderBatches) { var reminderEmbedBuilder = await CreateReminderEmbedAsync(reminderBatch); reminderEmbedBuilder.Footer = new LocalEmbedFooterBuilder { Text = $"Page [{++pageIndex}/{numberOfPages}]" }; reminderPages.Add(reminderEmbedBuilder.Build()); } var pageProvider = new DefaultPageProvider(reminderPages); var menu = new PagedMenu(Context.User.Id, pageProvider); await Context.Channel.StartMenuAsync(menu); }