private static async Task HandleQuoteReactions(Cacheable <IUserMessage, ulong> message, SocketReaction reaction) { // Check to see if the next page or previous page was clicked. if (reaction.Emote.Name == Extensions.Extensions.ArrowLeft.Name) { if (QuoteHandler.PageNumber[QuoteHandler.QuoteMessages.IndexOf(message.Id)] == 1) { return; } QuoteHandler.PageNumber[QuoteHandler.QuoteMessages.IndexOf(message.Id)]--; } else if (reaction.Emote.Name == Extensions.Extensions.ArrowRight.Name) { if (QuoteHandler.PageNumber[QuoteHandler.QuoteMessages.IndexOf(message.Id)] == QuoteHandler.GetQuotesListLength) { return; } QuoteHandler.PageNumber[QuoteHandler.QuoteMessages.IndexOf(message.Id)]++; } StringBuilder sb = new StringBuilder() .Append("**Quote List** : *Page " + QuoteHandler.PageNumber[QuoteHandler.QuoteMessages.IndexOf(message.Id)] + "*\n```"); List <string> quotes = QuoteHandler.GetQuotes(QuoteHandler.PageNumber[QuoteHandler.QuoteMessages.IndexOf(message.Id)]); for (int i = 0; i < quotes.Count; i++) { sb.Append(((i + 1) + ((QuoteHandler.PageNumber[QuoteHandler.QuoteMessages.IndexOf(message.Id)] - 1) * 10)) + ": " + quotes[i] + "\n"); } sb.Append("```"); await message.Value.ModifyAsync(msg => msg.Content = sb.ToString()); await message.Value.RemoveAllReactionsAsync(); if (QuoteHandler.PageNumber[QuoteHandler.QuoteMessages.IndexOf(message.Id)] == 1) { await message.Value.AddReactionAsync(Extensions.Extensions.ArrowRight); } else if (QuoteHandler.PageNumber[QuoteHandler.QuoteMessages.IndexOf(message.Id)] == QuoteHandler.GetQuotesListLength) { await message.Value.AddReactionAsync(Extensions.Extensions.ArrowLeft); } else { await message.Value.AddReactionAsync(Extensions.Extensions.ArrowLeft); await message.Value.AddReactionAsync(Extensions.Extensions.ArrowRight); } }
public async Task ListQuotes() { if (QuoteHandler.QuoteList.Count > 0) { StringBuilder sb = new StringBuilder(); QuoteHandler.SpliceQuotes(); List <string> quotesList = new List <string>(); int id = 0; for (int i = 0; i < QuoteHandler.GetQuotesListLength; i++) { List <string> quotes = QuoteHandler.GetQuotes(i + 1); foreach (var quote in quotes) { id++; sb.Append(id + ": " + quote + "\n"); } quotesList.Add(sb.ToString()); sb.Clear(); } PaginatedMessage message = new PaginatedMessage { Title = "**Quote List**", Color = new Color(User.Load(Context.User.Id).AboutR, User.Load(Context.User.Id).AboutG, User.Load(Context.User.Id).AboutB), Pages = quotesList, Options = new PaginatedAppearanceOptions() { DisplayInformationIcon = false } }; await PagedReplyAsync(message); } else { await ReplyAsync("There are no quotes in the database."); } }