public static EmbedBuilder FlipLoseEmbed(SocketGuildUser user, int amount) { var eb = new EmbedBuilder(); eb.WithAuthor(user); eb.WithDescription($"**You lose!** {amount.ToString("n0")} {ToastieUtil.RandomEmote()} lost...\nNow you have {BalanceDb.GetToasties(user.Id, user.Guild.Id).ToString("n0")} {ToastieUtil.RandomEmote()}!"); eb.WithColor(Color.DarkRed); return(eb); }
public static EmbedBuilder ToastieEmbed(IUser user, int amount) { var eb = new EmbedBuilder(); eb.WithAuthor(user); eb.WithDescription($"You have **{amount.ToString("n0")}** {ToastieUtil.RandomEmote()}!"); eb.WithColor(Color.Gold); return(eb); }
public static EmbedBuilder DailyGetEmbed(IUser user, int streak, int amount, int balance, string prefix) { var eb = new EmbedBuilder(); eb.WithAuthor(user.ToString(), user.GetAvatarUrl(), LinkHelper.GetRedirectUrl(LinkHelper.Patreon, "Patreon", "cmd-embed-daily")); eb.WithDescription($"You're on a **{streak.ToString("n0")}** day streak. You receive **{amount.ToString("n0")}** {ToastieUtil.RandomEmote()}\n" + $"Now you have **{balance.ToString("n0")}** {ToastieUtil.RandomEmote()}\n\n" + $"Vote for me on [Discord Bots]({LinkHelper.GetRedirectUrl(LinkHelper.Vote, "Vote", "cmd-daily")}) every day to receive a lootbox!"); eb.WithColor(BasicUtil.RandomColor()); if (!(PremiumDb.IsPremium(user.Id, ProType.Pro) || PremiumDb.IsPremium(user.Id, ProType.ProPlus))) { eb.WithFooter($"Check out Pro upgrades! `{prefix}Pro`"); } return(eb); }
public async Task BulkOpen([Remainder] string str = "") { var boxes = await LootBoxDb.GetAll(Context.User.Id, Context.Guild.Id); if (boxes.Count == 0) { await Context.Channel.SendMessageAsync("", false, ToastieUtil.NoBoxEmbed(Context.User).Build()); return; } LootBox box = null; if (boxes.Count == 1) { box = boxes[0]; } else { var listMsg = await Context.Channel.SendMessageAsync(embed : ToastieUtil.BoxListEmbed(boxes, Context.User) .WithFooter("Times out in 23 seconds") .WithDescription("Enter the number of the Lootbox type you wish to open.") .Build()); var response = await NextMessageAsync( new Criteria <IMessage>() .AddCriterion(new EnsureSourceUserCriterion()) .AddCriterion(new EnsureSourceChannelCriterion()) .AddCriterion(new EnsureRangeCriterion(boxes.Count, Program.GetPrefix(Context))), new TimeSpan(0, 0, 23)); _ = listMsg.DeleteAsync(); int i = 0; try { i = int.Parse(response.Content); } catch { _ = Context.Message.DeleteAsync(); return; } _ = response.DeleteAsync(); box = boxes[i - 1]; } var type = LootboxStats.Lootboxes[box.Type]; var dialoague = await ReplyAsync(embed : new EmbedBuilderPrepared(Context.User).WithDescription($"How many {type.Emote} **{type.Name}** lootboxes do you wish to open?").Build()); var amountMsg = await NextMessageAsync( new Criteria <IMessage>() .AddCriterion(new EnsureSourceUserCriterion()) .AddCriterion(new EnsureSourceChannelCriterion()) .AddCriterion(new EnsureRangeCriterion(int.MaxValue, Program.GetPrefix(Context))), new TimeSpan(0, 0, 23)); int amount; try { amount = int.Parse(amountMsg.Content); } catch { _ = Context.Message.DeleteAsync(); return; } _ = dialoague.DeleteAsync(); try { await LootBoxDb.AddLootbox(Context.User.Id, box.Type, -amount, box.GuildId); } catch { await Context.Channel.SendMessageAsync("You tried."); return; } _ = amountMsg.DeleteAsync(); var msg = await Context.Channel.SendMessageAsync("", false, ToastieUtil.BoxOpeningEmbed(Context.User).Build()); await ProfileDb.IncrementLootboxOpened(Context.User.Id, amount); int waitms = 4200; int toasties = 0; var waifusFound = new List <Waifu>(); var waifus = UserInventoryDb.GetWaifus(Context.User.Id, Context.Guild.Id); bool isPremium = PremiumDb.IsPremium(Context.User.Id, ProType.Pro); for (int i = 0; i < amount; i++) { if (type.IsWaifu()) { var waifu = await ToastieUtil.UnboxWaifu(type, isPremium, Context.User.Id, Context.Guild.Id); while (waifu == null || waifus.Any(x => x.Name.Equals(waifu.Name)) || waifusFound.Any(x => x.Name.Equals(waifu.Name))) { waifu = await ToastieUtil.UnboxWaifu(type, isPremium, Context.User.Id, Context.Guild.Id); } waifusFound.Add(waifu); await UserInventoryDb.AddWaifu(Context.User.Id, waifu, Context.Guild.Id); } else { toasties += type.GetRandomToasties(); } } await BalanceDb.AddToasties(Context.User.Id, toasties, Context.Guild.Id); var bal = BalanceDb.GetToasties(Context.User.Id, Context.Guild.Id); await Task.Delay(waitms); var eb = new EmbedBuilder() .WithAuthor($"{Context.User} | {box.Type.ToString()} x{amount}", Context.User.GetAvatarUrl(), LinkHelper.GetRedirectUrl(LinkHelper.Patreon, "Patreon", "cmd-embed-lootbox")) .WithColor(BasicUtil.RandomColor()) .WithThumbnailUrl("https://i.imgur.com/4JQmxa6.png"); string desc = $"You found **{toasties.ToString("n0")}** {ToastieUtil.RandomEmote()}!\nNow you have **{bal.ToString("n0")}** {ToastieUtil.RandomEmote()}!\n\n"; if (waifusFound.Any()) { desc += "**Waifus Found:**\n"; foreach (var w in waifusFound) { desc += $"`T{w.Tier}` **{w.Name}** - *{(w.Source.Length > 37 ? w.Source.Substring(0, 33) + "..." : w.Source)}*\n"; } } eb.WithDescription(desc.Length > 2000 ? desc.Substring(0, 1970) + "\n*And more...*" : desc); await msg.ModifyAsync(x => { x.Embed = eb.Build(); }); }
public async Task Open([Remainder] string str = "") { var boxes = await LootBoxDb.GetAll(Context.User.Id, Context.Guild.Id); if (boxes.Count == 0) { await Context.Channel.SendMessageAsync("", false, ToastieUtil.NoBoxEmbed(Context.User).Build()); return; } LootBox box = null; if (boxes.Count == 1) { box = boxes[0]; } else { var listMsg = await Context.Channel.SendMessageAsync(embed : ToastieUtil.BoxListEmbed(boxes, Context.User) .WithFooter("Times out in 23 seconds") .WithDescription("Enter the number of the Lootbox you wish to open.") .Build()); var response = await NextMessageAsync( new Criteria <IMessage>() .AddCriterion(new EnsureSourceUserCriterion()) .AddCriterion(new EnsureSourceChannelCriterion()) .AddCriterion(new EnsureRangeCriterion(boxes.Count, Program.GetPrefix(Context))), new TimeSpan(0, 0, 23)); _ = listMsg.DeleteAsync(); int i = 0; try { i = int.Parse(response.Content); } catch { _ = Context.Message.DeleteAsync(); return; } _ = response.DeleteAsync(); box = boxes[i - 1]; } var type = LootboxStats.Lootboxes[box.Type]; try { await LootBoxDb.AddLootbox(Context.User.Id, box.Type, -1, box.GuildId); } catch { await Context.Channel.SendMessageAsync("You tried."); return; } var msg = await Context.Channel.SendMessageAsync("", false, ToastieUtil.BoxOpeningEmbed(Context.User).Build()); await ProfileDb.IncrementLootboxOpened(Context.User.Id); int waitms = 4200; if (type.IsWaifu()) { bool isPremium = PremiumDb.IsPremium(Context.User.Id, ProType.Pro); var waifu = await ToastieUtil.UnboxWaifu(type, isPremium, Context.User.Id, Context.Guild.Id); while (UserInventoryDb.OwnsWaifu(Context.User.Id, waifu, Context.Guild.Id)) { waifu = await ToastieUtil.UnboxWaifu(type, isPremium, Context.User.Id, Context.Guild.Id); } await UserInventoryDb.AddWaifu(Context.User.Id, waifu, Context.Guild.Id); await Task.Delay(waitms); var embed = WaifuUtil.WaifuEmbedBuilder(waifu, Context).Build(); await msg.ModifyAsync(x => { x.Embed = embed; x.Content = $"{Context.User.Mention} Congratulations! You found **{waifu.Name}**!"; }); return; } var amountWon = type.GetRandomToasties(); await BalanceDb.AddToasties(Context.User.Id, amountWon, Context.Guild.Id); var bal = BalanceDb.GetToasties(Context.User.Id, Context.Guild.Id); await Task.Delay(waitms); await msg.ModifyAsync(x => { x.Embed = new EmbedBuilder() .WithAuthor($"{Context.User} | {box.Type.ToString()}", Context.User.GetAvatarUrl(), LinkHelper.GetRedirectUrl(LinkHelper.Patreon, "Patreon", "cmd-embed-lootbox")) .WithColor(BasicUtil.RandomColor()) .WithThumbnailUrl("https://i.imgur.com/4JQmxa6.png") .WithDescription($"Congratulations! You found **{amountWon.ToString("n0")}** {ToastieUtil.RandomEmote()}!\nNow you have **{bal.ToString("n0")}** {ToastieUtil.RandomEmote()}!") .Build(); }); }
public static EmbedBuilder GiveEmbed(IUser from, IUser to, int amount) { EmbedBuilder eb = new EmbedBuilder(); eb.AddField("Toasties <:toastie3:454441133876183060>", $"{from.Username} gave {to.Username} **{amount.ToString("n0")}** {ToastieUtil.RandomEmote()}!"); eb.WithColor(BasicUtil.RandomColor()); return(eb); }
public static async Task Forfeit(SocketCommandContext Context, BlackjackGame game) { var user = Context.User; await BalanceDb.AddToasties(user.Id, game.Toasties / 2, Context.Guild.Id); await BalanceDb.AddToasties(Context.Client.CurrentUser.Id, game.Toasties / 2, Context.Guild.Id); EmbedBuilder eb = new EmbedBuilder(); eb.WithAuthor(user.Username + " | You Lose", null, user.GetAvatarUrl()); eb.WithDescription("You forfeit. You get half your toasties back. Lost `" + game.Toasties / 2 + "`" + ToastieUtil.RandomEmote() + "\n" + "New balance `" + BalanceDb.GetToasties(user.Id, Context.Guild.Id) + "`" + ToastieUtil.RandomEmote()); eb.AddField("Your hand (" + game.SumHand(game.Hand) + ")", HandToString(game.Hand, false), true); eb.AddField("Namiko's hand (" + game.SumHand(game.Dealer) + ")", HandToString(game.Dealer, false), true); eb.WithColor(Color.DarkBlue); await Send(game, eb); games.Remove(user); }
public static async Task GameTimeout(SocketUser user, BlackjackGame game) { { EmbedBuilder eb = new EmbedBuilder(); var bot = game.Message.Author.Id; game.Stand(); if (game.SumHand(game.Hand) > 21) { await BalanceDb.AddToasties(bot, game.Toasties, game.Channel.Guild.Id); eb.WithAuthor(user.Username + " | Timeout", user.GetAvatarUrl()); eb.WithDescription("Your hand is a bust. You lose `" + game.Toasties + "` " + ToastieUtil.RandomEmote() + "\n" + "New balance `" + BalanceDb.GetToasties(user.Id, game.Channel.Guild.Id) + "` " + ToastieUtil.RandomEmote()); eb.WithColor(Color.DarkRed); } else if (game.SumHand(game.Hand) > game.SumHand(game.Dealer) || game.SumHand(game.Dealer) > 21) { await BalanceDb.AddToasties(user.Id, game.Toasties * 2, game.Channel.Guild.Id); await BalanceDb.AddToasties(bot, -game.Toasties, game.Channel.Guild.Id); eb.WithAuthor(user.Username + " | Timeout", user.GetAvatarUrl()); eb.WithDescription("Your score is higher than Namiko's. You win `" + game.Toasties + "` " + ToastieUtil.RandomEmote() + "\n" + "New balance `" + BalanceDb.GetToasties(user.Id, game.Channel.Guild.Id) + "` " + ToastieUtil.RandomEmote()); eb.WithColor(Color.Gold); } else if (game.SumHand(game.Hand) == game.SumHand(game.Dealer)) { await BalanceDb.AddToasties(user.Id, game.Toasties, game.Channel.Guild.Id); eb.WithAuthor(user.Username + " | Timeout", user.GetAvatarUrl()); eb.WithDescription("Your score is tied with Namiko's. You get your " + ToastieUtil.RandomEmote() + " back!\n" + "Your balance `" + BalanceDb.GetToasties(user.Id, game.Channel.Guild.Id) + "` " + ToastieUtil.RandomEmote()); eb.WithColor(Color.DarkGreen); } else { await BalanceDb.AddToasties(bot, game.Toasties, game.Channel.Guild.Id); eb.WithAuthor(user.Username + " | Timeout", user.GetAvatarUrl()); eb.WithDescription("Namiko's score is higher. You lose `" + game.Toasties + "` " + ToastieUtil.RandomEmote() + "\n" + "New balance `" + BalanceDb.GetToasties(user.Id, game.Channel.Guild.Id) + "` " + ToastieUtil.RandomEmote()); eb.WithColor(Color.DarkRed); } eb.AddField("Your hand (" + game.SumHand(game.Hand) + ")", HandToString(game.Hand, false), true); eb.AddField("Namiko's hand (" + game.SumHand(game.Dealer) + ")", HandToString(game.Dealer, false), true); await Send(game, eb); games.Remove(user); } }
public static async Task GameEnd(SocketCommandContext Context, BlackjackGame game) { EmbedBuilder eb = new EmbedBuilder(); var user = Context.User; if (game.SumHand(game.Hand) > 21) { await BalanceDb.AddToasties(Context.Client.CurrentUser.Id, game.Toasties, Context.Guild.Id); eb.WithAuthor(user.Username + " | You Lose", user.GetAvatarUrl()); eb.WithDescription("Your hand is a bust. You lose `" + game.Toasties + "` " + ToastieUtil.RandomEmote() + "\n" + "New balance `" + BalanceDb.GetToasties(user.Id, Context.Guild.Id) + "` " + ToastieUtil.RandomEmote()); eb.WithColor(Color.DarkRed); } else if (game.SumHand(game.Hand) > game.SumHand(game.Dealer) || game.SumHand(game.Dealer) > 21) { await BalanceDb.AddToasties(user.Id, game.Toasties * 2, Context.Guild.Id); await BalanceDb.AddToasties(Context.Client.CurrentUser.Id, -game.Toasties, Context.Guild.Id); eb.WithAuthor(user.Username + " | You Win", user.GetAvatarUrl()); eb.WithDescription("Your score is higher than Namiko's. You win `" + game.Toasties + "` " + ToastieUtil.RandomEmote() + "\n" + "New balance `" + BalanceDb.GetToasties(user.Id, Context.Guild.Id) + "` " + ToastieUtil.RandomEmote()); eb.WithColor(Color.Gold); } else if (game.SumHand(game.Hand) == game.SumHand(game.Dealer)) { await BalanceDb.AddToasties(user.Id, game.Toasties, Context.Guild.Id); eb.WithAuthor(user.Username + " | Tie", user.GetAvatarUrl()); eb.WithDescription("Your score is tied with Namiko's. You get your " + ToastieUtil.RandomEmote() + " back!\n" + "Your balance `" + BalanceDb.GetToasties(user.Id, Context.Guild.Id) + "` " + ToastieUtil.RandomEmote()); eb.WithColor(Color.DarkGreen); } else { await BalanceDb.AddToasties(Context.Client.CurrentUser.Id, game.Toasties, Context.Guild.Id); eb.WithAuthor(user.Username + " | You Lose", user.GetAvatarUrl()); eb.WithDescription("Namiko's score is higher. You lose `" + game.Toasties + "` " + ToastieUtil.RandomEmote() + "\n" + "New balance `" + BalanceDb.GetToasties(user.Id, Context.Guild.Id) + "` " + ToastieUtil.RandomEmote()); eb.WithColor(Color.DarkRed); } eb.AddField("Your hand (" + game.SumHand(game.Hand) + ")", HandToString(game.Hand, false), true); eb.AddField("Namiko's hand (" + game.SumHand(game.Dealer) + ")", HandToString(game.Dealer, false), true); await Send(game, eb); games.Remove(user); }