public async Task Top(CommandContext ctx) { var api = new CoinmarketcapAPI(); try { string json = api.ListingsLatest(1, 15); //Try to get currencies var cryptocurrencies = JsonConvert.DeserializeObject <Listing>(json); var embed = new DiscordEmbedBuilder() { Author = new DiscordEmbedBuilder.EmbedAuthor { IconUrl = "https://i.ibb.co/wQ3JJ7c/podium.png", Url = "https://coinmarketcap.com/", Name = "CoinMarketCap" }, Color = DiscordColor.Orange, Timestamp = DateTime.Now, Title = $"Top 15 cryptocurrecies by Market Cap" }; embed.AddField($"{DiscordText.BoldUnderLine("# - Name")}", $":first_place: **- {cryptocurrencies.DataList[0].Name} {cryptocurrencies.DataList[0].Symbol}**", true); embed.AddField($"{DiscordText.BoldUnderLine($"Price {DiscordText.Italic("(USD)")}")}", $"**${Numbers.EditToReadableNumber(cryptocurrencies.DataList[0].Quote["USD"].Price)}**", true); embed.AddField($"{DiscordText.BoldUnderLine($"Market Cap {DiscordText.Italic("(USD)")}")}", $"**${Numbers.EditToReadableNumber(cryptocurrencies.DataList[0].Quote["USD"].MarketCap)}**", true); for (int z = 0, i = 1, k = 2; z < 7; z++, i = i + 2, k = k + 2) { string line1 = string.Empty; string line2 = string.Empty; if (cryptocurrencies.DataList[i].Rank == 2 && cryptocurrencies.DataList[k].Rank == 3) { line1 = $":second_place: {DiscordText.Bold($"- {cryptocurrencies.DataList[i].Name} {cryptocurrencies.DataList[i].Symbol}")}"; line2 = $":third_place: {DiscordText.Bold($"- {cryptocurrencies.DataList[k].Name} {cryptocurrencies.DataList[k].Symbol}")}"; } else { line1 = $"{DiscordText.Bold($"{cryptocurrencies.DataList[i].Rank} - {cryptocurrencies.DataList[i].Name} {cryptocurrencies.DataList[i].Symbol}")}"; line2 = $"{DiscordText.Bold($"{cryptocurrencies.DataList[k].Rank} - {cryptocurrencies.DataList[k].Name} {cryptocurrencies.DataList[k].Symbol}")}"; } embed.AddField(line1, line2, true); embed.AddField( $"{DiscordText.Bold($"${Numbers.EditToReadableNumber(cryptocurrencies.DataList[i].Quote["USD"].Price)}")}", $"{DiscordText.Bold($"${Numbers.EditToReadableNumber(cryptocurrencies.DataList[k].Quote["USD"].Price)}")}", true); embed.AddField( $"{DiscordText.Bold($"${Numbers.EditToReadableNumber(cryptocurrencies.DataList[i].Quote["USD"].MarketCap)}")}", $"{DiscordText.Bold($"${Numbers.EditToReadableNumber(cryptocurrencies.DataList[k].Quote["USD"].MarketCap)}")}", true); } await ctx.Channel.SendMessageAsync(embed : embed); } catch (Exception ex) { BotLoging.PrintError(ctx.Client, ctx.User, ex); } }
public async Task Conversion(CommandContext ctx) => await Prompt.SendPromptAsync(ctx.Channel, ctx.User, $"Enter {DiscordText.SingleLineCode("+help convert")} to see how the command works");
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); } }