private string GetEditedPrices(List <Model.Coinmarketcap.Data> datas) { string result = string.Empty; foreach (var item in datas) { result += DiscordText.MultyLineCode($"${Numbers.EditToReadableNumber(item.Quote.First().Value.Price)}"); } return(result); }
private string GetEditedNames(List <Model.Coinmarketcap.Data> datas) { string result = string.Empty; foreach (var item in datas) { result += DiscordText.MultyLineCode($"#{item.Rank} - {item.Name} ({item.Symbol})"); } return(DiscordText.Bold(result)); }
private string GetEditedAmount(List <Model.Coinmarketcap.Data> datas, string criteria) { string result = string.Empty; List <ulong> amount = new List <ulong>(); switch (criteria) { case "volume24h": datas.ForEach(x => amount.Add(x.Quote.First().Value.Volume24h)); break; case "marketcap": datas.ForEach(x => amount.Add(x.Quote.First().Value.MarketCap)); break; } foreach (var item in amount) { result += DiscordText.MultyLineCode($"${Numbers.EditToReadableNumber(item)}"); } return(result); }
public async Task Earn(CommandContext ctx) { var duration = TimeSpan.FromSeconds(600); try { var earns = Headlines.Earn; var embedsList = new List <DiscordEmbed>(); if (earns == null) { throw new Exception("Earn companies has not been uploaded yet"); } for (int j = 0; j < earns.Count; j++) { embedsList.Add( new DiscordEmbedBuilder { Author = new DiscordEmbedBuilder.EmbedAuthor { Name = earns[j].Name + " " + earns[j].Symbol, IconUrl = earns[j].IconUrl, Url = earns[j].Url }, Thumbnail = new DiscordEmbedBuilder.EmbedThumbnail { Url = earns[j].IconUrl, }, Footer = new DiscordEmbedBuilder.EmbedFooter { Text = $"Page {j + 1} / {earns.Count}" }, Description = earns[j].Description, ImageUrl = earns[j].ImageUrl, Color = DiscordColor.Purple } .AddField(DiscordText.BoldUnderLine("Campaign status:"), (earns[j].Live) ? DiscordText.Bold(DiscordText.MultyLineCode("LIVE")) : DiscordText.Bold(DiscordText.MultyLineCode("DONE"))) .Build()); } int messageIterator = 0; var message = await ctx.Channel.SendMessageAsync(embed : embedsList[messageIterator]).ConfigureAwait(false); var toFirstEmoji = DiscordEmoji.FromName(ctx.Client, ":one:"); var arrowLeftEmoji = DiscordEmoji.FromName(ctx.Client, ":arrow_backward:"); var arrowRightEmoji = DiscordEmoji.FromName(ctx.Client, ":arrow_forward:"); await message.CreateReactionAsync(toFirstEmoji).ConfigureAwait(false); await message.CreateReactionAsync(arrowLeftEmoji).ConfigureAwait(false); await message.CreateReactionAsync(arrowRightEmoji).ConfigureAwait(false); await Task.Delay(400); var interactivity = ctx.Client.GetInteractivity(); while (true) { var reactionResult = await interactivity.WaitForReactionAsync( x => x.Message == message && ( x.Emoji == toFirstEmoji | x.Emoji == arrowLeftEmoji | x.Emoji == arrowRightEmoji), duration) .ConfigureAwait(false); if (reactionResult.Result == null) { break; } if (reactionResult.Result.Emoji == toFirstEmoji) { messageIterator = 0; await message.DeleteReactionAsync(toFirstEmoji, reactionResult.Result.User).ConfigureAwait(false); } else if (reactionResult.Result.Emoji == arrowLeftEmoji) { _ = (messageIterator > 0) ? messageIterator-- : messageIterator = 9; await message.DeleteReactionAsync(arrowLeftEmoji, reactionResult.Result.User).ConfigureAwait(false); } else if (reactionResult.Result.Emoji == arrowRightEmoji) { _ = (messageIterator < 9) ? messageIterator++ : messageIterator = 0; await message.DeleteReactionAsync(arrowRightEmoji, reactionResult.Result.User).ConfigureAwait(false); } await message.ModifyAsync(embedsList[messageIterator]).ConfigureAwait(false); } } catch (Exception ex) { BotLoging.PrintError(ctx.Client, ctx.User, ex); } }