public async Task ShipWaifu(string name, ulong userId, ulong guildId = 0) { Program.GetPrefix(Context); if (guildId == 0) { guildId = Context.Guild.Id; } var waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(name), this); if (waifu == null) { return; } if (UserInventoryDb.OwnsWaifu(userId, waifu, guildId)) { await Context.Channel.SendMessageAsync($"They already own **{waifu.Name}**"); return; } await UserInventoryDb.AddWaifu(userId, waifu, guildId); await Context.Channel.SendMessageAsync($"**{waifu.Name}** shipped!"); }
public async Task ShipWaifu(IUser user, [Remainder] string name) { var waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(name), this); if (waifu == null) { return; } if (waifu.Tier < 1 || waifu.Tier > 3) { if (!(Context.Guild.Id == 738291903770132646 && waifu.Tier == 825)) { await Context.Channel.SendMessageAsync(embed : new EmbedBuilderPrepared(Context.User) .WithDescription($"*~ You can only ship Tier 1-3 waifus ~*") .Build()); return; } } if (UserInventoryDb.OwnsWaifu(user.Id, waifu, Context.Guild.Id)) { await Context.Channel.SendMessageAsync($"They already own **{waifu.Name}**"); return; } await UserInventoryDb.AddWaifu(user.Id, waifu, Context.Guild.Id); await Context.Channel.SendMessageAsync($"**{waifu.Name}** shipped!", embed : WaifuUtil.WaifuEmbedBuilder(waifu).Build()); }
public async Task GiveWaifu(IUser recipient, [Remainder] string str = "") { var waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(str, false, UserInventoryDb.GetWaifus(Context.User.Id, Context.Guild.Id)), this); if (waifu == null) { return; } var waifus = UserInventoryDb.GetWaifus(Context.User.Id, Context.Guild.Id); if (!waifus.Any(x => x.Name.Equals(waifu.Name))) { await Context.Channel.SendMessageAsync($"**{waifu.Name}** is just like my love - you don't have it."); return; } waifus = UserInventoryDb.GetWaifus(recipient.Id, Context.Guild.Id); if (waifus.Any(x => x.Name.Equals(waifu.Name))) { await Context.Channel.SendMessageAsync($"They already have **{waifu.Name}**."); return; } await UserInventoryDb.AddWaifu(recipient.Id, waifu, Context.Guild.Id); await UserInventoryDb.DeleteWaifu(Context.User.Id, waifu, Context.Guild.Id); await Context.Channel.SendMessageAsync($"{recipient.Mention} You received **{waifu.Name}** from {Context.User.Mention}!", false, WaifuUtil.WaifuEmbedBuilder(waifu).Build()); }
public async Task BuyWaifu([Remainder] string str = "") { var shopwaifus = (await WaifuShopDb.GetAllShopWaifus(Context.Guild.Id)).DistinctBy(x => x.WaifuName); var waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(str, false, shopwaifus.Select(x => x.Waifu)), this); if (waifu == null) { return; } var waifus = UserInventoryDb.GetWaifus(Context.User.Id, Context.Guild.Id); if (waifus.Any(x => x.Name.Equals(waifu.Name))) { await Context.Channel.SendMessageAsync("You already have **" + waifu.Name + "**."); return; } ShopWaifu shopWaifu = shopwaifus.FirstOrDefault(x => x.Waifu.Equals(waifu) && x.Limited != 0); if (shopWaifu == null) { await Context.Channel.SendMessageAsync($"**{waifu.Name}** is not currently for sale! Try the `waifushop` command."); return; } var price = WaifuUtil.GetPrice(waifu.Tier, shopWaifu.Discount); try { await BalanceDb.AddToasties(Context.User.Id, -price, Context.Guild.Id); } catch (Exception ex) { await Context.Channel.SendMessageAsync(ex.Message); return; } await UserInventoryDb.AddWaifu(Context.User.Id, waifu, Context.Guild.Id); await Context.Channel.SendMessageAsync($"Congratulations! You bought **{waifu.Name}**!", false, WaifuUtil.WaifuEmbedBuilder(waifu).Build()); await BalanceDb.AddToasties(Context.Client.CurrentUser.Id, price / 13, Context.Guild.Id); if (shopWaifu.Limited > 0) { shopWaifu.BoughtBy = Context.User.Id; shopWaifu.Limited -= 1; await WaifuShopDb.UpdateItem(shopWaifu); } }
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(); }); }