private async Task ProcessList() { try { IMessageChannel channel = await ChannelProvider.GetDMChannelAsync(this.Context); List <TReminder> reminders = this._reminderDAO.GetAll(this.Context.User.Id); IOrderedEnumerable <TReminder> orderedList = reminders.OrderBy(x => x.ExpirationTime); FormattedEmbedBuilder message = new FormattedEmbedBuilder() .AppendTitle($"{XayahReaction.Hourglass} Active reminders"); if (orderedList.Count() > 0) { foreach (TReminder entry in orderedList) { message.AddField($"Expires: {entry.ExpirationTime} UTC", entry.Message, inline: false); } } else { message.AppendDescription("imagine a soulrending void", AppendOption.Italic); } await channel.SendEmbedAsync(message); await this.Context.Message.AddReactionIfNotDMAsync(this.Context, XayahReaction.Envelope); } catch (Exception ex) { Logger.Error(ex); } }
public async Task <FormattedEmbedBuilder> BuildForRoleAsync(LeagueRole role) { FormattedEmbedBuilder message = new FormattedEmbedBuilder(); try { await this.LoadFromApi(); if (LeagueRole.All.Equals(role)) { foreach (LeagueRole leagueRole in LeagueRole.Values()) { this.AppendStatsOfRole(leagueRole, 3, message); } } else { this.AppendStatsOfRole(role, 6, message); } message.AppendTitle($"{XayahReaction.Clipboard} Winrates"); ChampionStatsDto first = this._championStats.ElementAtOrDefault(0); if (first != null) { message.AppendTitle($" for Patch {first.Patch}"); } message.AppendDescription("Short explanation of the table: `Position - Win % - Play %` - Name", AppendOption.Italic); } catch (NoApiResultException) { message = new FormattedEmbedBuilder() .AppendTitle($"{XayahReaction.Error} This didn't work") .AppendDescription("Apparently some random API refuses cooperation. Have some patience while I convince them again..."); } return(message); }
public static async Task <FormattedEmbedBuilder> BuildAsync(string name) { name = name.Trim(); ChampionDataBuilder championBuilder = new ChampionDataBuilder(); FormattedEmbedBuilder message = new FormattedEmbedBuilder(); try { List <ChampionDto> matches = await championBuilder.GetMatchingChampionsAsync(name); if (matches.Count == 0) { message .AppendTitle($"{XayahReaction.Error} This didn't work") .AppendDescription($"Oops! Your bad. I couldn't find a champion (fully or partially) named `{name}`."); } else if (matches.Count > 1) { message .AppendTitle($"{XayahReaction.Warning} This didn't went as expected") .AppendDescription($"I found more than one champion (fully or partially) named `{name}`."); foreach (ChampionDto champion in matches) { message.AppendDescription(Environment.NewLine + champion.Name); } } else { ChampionDto champion = await championBuilder.GetChampionAsync(matches.First().Id); championBuilder.AppendMiscData(champion, message); championBuilder.AppendStatisticData(champion, message); championBuilder.AppendSpellData(champion, message); championBuilder.AppendSkinData(champion, message); } } catch (NoApiResultException) { message = new FormattedEmbedBuilder() .AppendTitle($"{XayahReaction.Error} This didn't work") .AppendDescription("Apparently some random API refuses cooperation. Have some patience while I convince them again..."); } return(message); }
public static async Task <FormattedEmbedBuilder> BuildAsync(string name) { name = name.Trim(); ItemDataBuilder itemBuilder = new ItemDataBuilder(); FormattedEmbedBuilder message = new FormattedEmbedBuilder(); try { List <ItemDto> matches = await itemBuilder.GetMatchingItemsAsync(name); if (matches.Count == 0) { message .AppendTitle($"{XayahReaction.Error} This didn't work") .AppendDescription($"Oops! Your bad. I couldn't find an item (fully or partially) named `{name}`."); } else if (matches.Count > 1) { message .AppendTitle($"{XayahReaction.Warning} This didn't went as expected") .AppendDescription($"I found more than one item (fully or partially) named `{name}`."); foreach (ItemDto item in matches) { message.AppendDescription(Environment.NewLine + item.Name); } } else { ItemDto item = matches.First(); await itemBuilder.AppendData(item, message); } } catch (NoApiResultException) { message = new FormattedEmbedBuilder() .AppendTitle($"{XayahReaction.Error} This didn't work") .AppendDescription("Apparently some random API refuses cooperation. Have some patience while I convince them again..."); } return(message); }
private FormattedEmbedBuilder AppendDescriptionTitle(FormattedEmbedBuilder message, string text) { return(message.AppendDescription(text, AppendOption.Underscore).AppendDescriptionNewLine()); }