Пример #1
0
        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!");
        }
Пример #2
0
        public async Task WaifuMal(string name, long malId)
        {
            var waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(name, true, includeMAL: true), this);

            if (waifu == null)
            {
                return;
            }

            var mal = waifu.Mal ?? new MalWaifu {
                WaifuName = waifu.Name
            };

            mal.LastUpdated  = DateTime.Now;
            mal.MalConfirmed = true;
            mal.MalId        = malId;

            if ((await WaifuDb.UpdateMalWaifu(mal)) > 0)
            {
                await Context.Channel.SendMessageAsync($":white_check_mark: {waifu.Name} updated.");
            }
            else
            {
                await Context.Channel.SendMessageAsync($":x: Failed to update {name}");
            }
        }
Пример #3
0
        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());
        }
Пример #4
0
        public async Task WaifuImageSource([Remainder] string name)
        {
            var waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(name, true, null, true), this);

            if (waifu == null)
            {
                return;
            }

            string str = "```yaml\n";

            str += $"Name: {waifu.Name}\n";
            str += $"FullName: {waifu.LongName}\n";
            str += $"Source: {waifu.Source}\n";
            str += $"Description: {waifu.Description}\n";
            str += $"ImgurUrl: {waifu.ImageUrl}\n";
            str += $"NamikoMoeUrl: {waifu.HostImageUrl}\n";
            str += $"ImageSource: {waifu.ImageSource}\n";
            str += $"Tier: {waifu.Tier}\n";
            str += $"MalId: {waifu.Mal?.MalId}\n";

            str += "```";

            await Context.Channel.SendMessageAsync(str);
        }
Пример #5
0
        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());
        }
Пример #6
0
        public async Task <IEnumerable <WaifuView> > Search([FromQuery] string search)
        {
            var res = await WaifuDb.SearchWaifus(search, perPage : 50).ConfigureAwait(false);

            var waifus = res.ToView();

            waifus = waifus.OrderByDescending(x => x.Bought).ToList();
            return(waifus);
        }
Пример #7
0
        public async Task SellWaifu([Remainder] string str = "")
        {
            var waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(str, false, UserInventoryDb.GetWaifus(Context.User.Id, Context.Guild.Id)), this);

            //waifus existance
            if (waifu == null)
            {
                return;
            }

            int worth = WaifuUtil.GetSalePrice(waifu.Tier);

            var sell = new DialogueBoxOption();

            sell.Action = async(IUserMessage message) =>
            {
                if (!UserInventoryDb.OwnsWaifu(Context.User.Id, waifu, Context.Guild.Id))
                {
                    await message.ModifyAsync(x => {
                        x.Embed = new EmbedBuilderPrepared(Context.User).WithDescription("You tried :star:").Build();
                    });

                    return;
                }

                try { await BalanceDb.AddToasties(Context.User.Id, worth, Context.Guild.Id); }
                catch (Exception ex) { await Context.Channel.SendMessageAsync(ex.Message); }

                //removing waifu + confirmation
                await UserInventoryDb.DeleteWaifu(Context.User.Id, waifu, Context.Guild.Id);

                await message.ModifyAsync(x => {
                    x.Content = $"You sold **{waifu.Name}** for **{worth.ToString("n0")}** toasties.";
                    x.Embed   = ToastieUtil.ToastieEmbed(Context.User, BalanceDb.GetToasties(Context.User.Id, Context.Guild.Id)).Build();
                });
            };
            sell.After = OnExecute.RemoveReactions;

            var cancel = new DialogueBoxOption();

            cancel.After = OnExecute.Delete;

            var dia = new DialogueBox();

            dia.Options.Add(Emote.Parse("<:TickYes:577838859107303424>"), sell);
            dia.Options.Add(Emote.Parse("<:TickNo:577838859077943306>"), cancel);
            dia.Timeout = new TimeSpan(0, 1, 0);
            dia.Embed   = new EmbedBuilder()
                          .WithAuthor(Context.User)
                          .WithColor(BasicUtil.RandomColor())
                          .WithDescription($"Sell **{waifu.Name}** for **{worth.ToString("n0")}** toasties?").Build();

            await DialogueReplyAsync(dia);

            return;
        }
Пример #8
0
        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);
            }
        }
Пример #9
0
 public async Task DeleteWaifu(string name)
 {
     if (await WaifuDb.DeleteWaifu(name) > 0)
     {
         await Context.Channel.SendMessageAsync($"{name} deleted.");
     }
     else
     {
         await Context.Channel.SendMessageAsync($"Failed to delete {name}");
     }
 }
Пример #10
0
        public static async Task<List<ShopWaifu>> GenerateGachaShopList(ulong guildId)
        {
            int t1amount = Constants.gachat1amount;
            int t2amount = Constants.gachat2amount;
            int t3amount = Constants.gachat3amount;
            int pages = 1;
            if (PremiumDb.IsPremium(guildId, ProType.GuildPlus) || PremiumDb.IsPremium(guildId, ProType.Guild))
                pages = 3;
            int randomizerMultiplier = 7 - pages;

            var waifus = new List<Waifu>();

            var gachaSource = GetGachaSources();
            waifus.AddRange(await WaifuDb.RandomWaifus(1, t1amount * pages * randomizerMultiplier, includeSource: gachaSource));
            waifus.AddRange(await WaifuDb.RandomWaifus(2, t2amount * pages * randomizerMultiplier, includeSource: gachaSource));
            waifus.AddRange(await WaifuDb.RandomWaifus(3, t3amount * pages * randomizerMultiplier, includeSource: gachaSource));

            var wishlists = await WaifuWishlistDb.GetAllPremiumWishlists(guildId, ProType.Pro);
            wishlists.RemoveAll(x => !gachaSource.Contains(x.Waifu.Source));
            var ids = wishlists.Select(x => x.UserId).Distinct().ToArray();
            var guild = Program.GetClient().GetGuild(guildId);
            foreach (var id in ids)
            {
                SocketGuildUser user = null;
                try
                {
                    user = guild.GetUser(id);
                }
                catch
                {
                    wishlists.RemoveAll(x => x.UserId == id);
                }
                if (user == null)
                    wishlists.RemoveAll(x => x.UserId == id);
            }
            waifus.AddRange(wishlists.Select(x => x.Waifu));

            ShopWaifu item = null;
            List<ShopWaifu> finalWaifus = new List<ShopWaifu>();
            var rnd = new Random();
            int r = 0;

            for (int k = 0; k < Constants.gachatotal * pages; k++)
            {
                r = rnd.Next(0, waifus.Count);
                item = new ShopWaifu { Waifu = waifus.ElementAt(r), Limited = -1, BoughtBy = 0 };
                finalWaifus.Add(item);
                waifus.RemoveAll(x => x.Name.Equals(waifus[r].Name));
            }

            return finalWaifus.OrderBy(x => x.Waifu.Tier).ToList();
        }
Пример #11
0
        public async Task WishWaifu([Remainder] string str = "")
        {
            var   user  = Context.User;
            Waifu waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(str), this);

            if (waifu == null)
            {
                return;
            }

            var waifus = await WaifuWishlistDb.GetWishlist(user.Id, Context.Guild.Id);

            int cap = 5;

            if (PremiumDb.IsPremium(Context.User.Id, ProType.ProPlus))
            {
                cap = 12;
            }

            string prefix = Program.GetPrefix(Context);

            if (waifus.Count >= cap)
            {
                await Context.Channel.SendMessageAsync(embed : new EmbedBuilderPrepared(Context.User)
                                                       .WithDescription($"You have reached your wishlist limit of **{cap}**.\n" +
                                                                        $"Try `{prefix}rww` to remove a waifu.")
                                                       .WithFooter($"Increase the limit: `{prefix}pro`")
                                                       .Build());

                return;
            }

            if (waifus.Any(x => x.Name == waifu.Name))
            {
                await Context.Channel.SendMessageAsync($"**{waifu.Name}** is already in your wishlist. Baka.");

                return;
            }

            if (UserInventoryDb.OwnsWaifu(user.Id, waifu, Context.Guild.Id))
            {
                await Context.Channel.SendMessageAsync($"You already own **{waifu.Name}**. Baka.");

                return;
            }

            await WaifuWishlistDb.AddWaifuWish(Context.User.Id, waifu, Context.Guild.Id);

            waifus = await WaifuWishlistDb.GetWishlist(user.Id, Context.Guild.Id);

            await Context.Channel.SendMessageAsync($"Added **{waifu.Name}** to your wishlist!", false, WaifuUtil.WishlistEmbed(waifus, (SocketGuildUser)user).Build());
        }
Пример #12
0
        public async Task ShowWaifu([Remainder] string name)
        {
            var waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(name), this);

            if (waifu == null)
            {
                //await Context.Channel.SendMessageAsync($"Can't find '{name}'. I know they are not real, but this one *really is* just your imagination >_>");
                return;
            }

            var eb = WaifuUtil.WaifuEmbedBuilder(waifu, Context);

            await Context.Channel.SendMessageAsync("", false, eb.Build());
        }
Пример #13
0
        // LOOTBOX

        public static async Task <Waifu> UnboxWaifu(LootboxStat box, bool isPremium = false, ulong userId = 0, ulong guildId = 0)
        {
            var          rnd              = new Random();
            List <Waifu> waifus           = new List <Waifu>();
            int          randomizerAmount = 7;

            int tier = box.GetRandomTier();

            waifus.AddRange(await WaifuDb.RandomWaifus(tier, randomizerAmount));

            if (isPremium)
            {
                waifus.AddRange((await WaifuWishlistDb.GetWishlist(userId, guildId)).Where(x => x.Tier == tier));
            }

            return(waifus[rnd.Next(waifus.Count)]);
        }
Пример #14
0
        public async Task AutocompleteWaifu(string name, long malId)
        {
            var waifu = await WaifuDb.GetWaifu(name);

            if (waifu == null)
            {
                await Context.Channel.SendMessageAsync($"**{name}** doesn't exist. *BAAAAAAAAAAAAAAAAAAKA*");

                return;
            }

            var mal = await WebUtil.GetWaifu(malId);

            waifu.LongName = $"{mal.Name} ({mal.NameKanji})";
            var    about = mal.About;
            var    lines = about.Split('\n');
            string desc  = "";

            foreach (var line in lines)
            {
                if (line.Split(' ')[0].EndsWith(':'))
                {
                    continue;
                }
                if (line.StartsWith('('))
                {
                    continue;
                }

                var l = Regex.Replace(line, @"\t|\n|\r|\\n|\\t|\\r", "");
                if (l != "")
                {
                    desc += l + "\n\n";
                }
            }
            //desc.Replace(@"\r", @"\n\n");
            waifu.Description = desc;
            waifu.Source      = mal.Animeography.FirstOrDefault() == null ? "" : mal.Animeography.FirstOrDefault().Name;

            await WaifuDb.UpdateWaifu(waifu);

            await Context.Channel.SendMessageAsync($"Autocompleted **{waifu.Name}**. Has **{mal.MemberFavorites}** favorites.", false, WaifuUtil.WaifuEmbedBuilder(waifu, Context).Build());
        }
Пример #15
0
        public async Task ModShopRemoveWaifu([Remainder] string name = "")
        {
            var shop = await WaifuUtil.GetShop(Context.Guild.Id, ShopType.Mod);

            var waifus = shop.ShopWaifus.Select(x => x.Waifu);

            var waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(name, false, waifus), this);

            if (waifu == null)
            {
                return;
            }

            await WaifuShopDb.RemoveItem(shop.ShopWaifus.FirstOrDefault(x => x.Waifu.Name.Equals(waifu.Name)));

            await Context.Channel.SendMessageAsync(embed : new EmbedBuilderPrepared(Context.User)
                                                   .WithDescription($"*~ **{waifu.Name}** removed from the Mod Shop ~*")
                                                   .Build());

            return;
        }
Пример #16
0
        public async Task ServerTopWaifus([Remainder] string str = "")
        {
            var waifus = await UserInventoryDb.CountWaifus(Context.Guild.Id, str.Split(' '));

            var msg = new CustomPaginatedMessage();

            msg.Title = ":two_hearts: Waifu Leaderboards";
            var fields = new List <FieldPages>
            {
                new FieldPages
                {
                    Title = "Bought Here",
                    Pages = CustomPaginatedMessage.PagesArray(waifus, 10, (x) => $"**{x.Key}** - {x.Value}\n")
                }
            };

            msg.Fields       = fields;
            msg.ThumbnailUrl = (await WaifuDb.GetWaifu(waifus.First().Key)).HostImageUrl;

            await PagedReplyAsync(msg);
        }
Пример #17
0
        public async Task RemoveWaifuWish([Remainder] string str = "")
        {
            var   user  = Context.User;
            Waifu waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(str, false, await WaifuWishlistDb.GetWishlist(Context.User.Id, Context.Guild.Id)), this);

            if (waifu == null)
            {
                return;
            }
            var waifus = await WaifuWishlistDb.GetWishlist(user.Id, Context.Guild.Id);

            if (!waifus.Any(x => x.Name == waifu.Name))
            {
                await Context.Channel.SendMessageAsync($"**{waifu.Name}** is not in your wishlist. Baka.");

                return;
            }

            await WaifuWishlistDb.DeleteWaifuWish(user.Id, waifu, Context.Guild.Id);

            await Context.Channel.SendMessageAsync("You don't want her anymore, huh...");
        }
Пример #18
0
        public async Task WaifuSource(string name, [Remainder] string source = null)
        {
            var waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(name, true), this);

            if (waifu == null)
            {
                return;
            }

            string old = waifu.Source;

            waifu.Source = source;

            if (await WaifuDb.UpdateWaifu(waifu) > 0)
            {
                await SendWaifuUpdatedMessage(waifu, "Source", old, waifu.Source);
            }
            else
            {
                await Context.Channel.SendMessageAsync($":x: Failed to update {name}");
            }
        }
Пример #19
0
        public async Task WaifuTier(string name, int tier)
        {
            var waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(name, true), this);

            if (waifu == null)
            {
                return;
            }

            string old = waifu.Tier.ToString();

            waifu.Tier = tier;

            if (await WaifuDb.UpdateWaifu(waifu) > 0)
            {
                await SendWaifuUpdatedMessage(waifu, "Tier", old, waifu.Tier.ToString());
            }
            else
            {
                await Context.Channel.SendMessageAsync($":x: Failed to update {name}");
            }
        }
Пример #20
0
        public async Task RenameWaifu(string oldName, string newName)
        {
            var waifu = await WaifuDb.GetWaifu(oldName);

            if (waifu == null)
            {
                await Context.Channel.SendMessageAsync($"**{oldName}** doesn't exist. *BAAAAAAAAAAAAAAAAAAKA*");

                return;
            }

            waifu = await WaifuDb.GetWaifu(newName);

            if (waifu != null)
            {
                await Context.Channel.SendMessageAsync($"**{newName}** already exists! *BAAAAAAAAAAAAAAAAAAKA*");

                return;
            }

            int res = await WaifuDb.RenameWaifu(oldName, newName);

            await Context.Channel.SendMessageAsync($"Replaced **{res}** **{oldName}** with their **{newName}** clones and burned the originals. *That was wild...*");
        }
Пример #21
0
        public static async Task<List<ShopWaifu>> GenerateWaifuShopList(ulong guildId)
        {
            int limitedamount = Constants.shoplimitedamount;
            int t1amount = Constants.shopt1amount;
            int t2amount = Constants.shopt2amount;
            int t3amount = Constants.shopt3amount;
            int pages = 1;
            if (PremiumDb.IsPremium(guildId, ProType.GuildPlus) || PremiumDb.IsPremium(guildId, ProType.Guild))
                pages = 3;
            int randomizerMultiplier = 7 - pages;

            var gachaSource = GetGachaSources();
            var tier0 = await WaifuDb.GetWaifusByTier(0);
            var tier1 = await WaifuDb.RandomWaifus(1, (limitedamount + t1amount) * pages * randomizerMultiplier, excludeSource: gachaSource);
            var tier2 = await WaifuDb.RandomWaifus(2, t2amount * pages * randomizerMultiplier, excludeSource: gachaSource);
            var tier3 = await WaifuDb.RandomWaifus(3, t3amount * pages * randomizerMultiplier, excludeSource: gachaSource);

            var wishlists = await WaifuWishlistDb.GetAllPremiumWishlists(guildId, ProType.Pro);
            wishlists.RemoveAll(x => gachaSource.Contains(x.Waifu.Source));
            var ids = wishlists.Select(x => x.UserId).Distinct().ToArray();
            var guild = Program.GetClient().GetGuild(guildId);
            foreach (var id in ids)
            {
                SocketGuildUser user = null;
                try
                {
                    user = guild.GetUser(id);
                }
                catch
                {
                    wishlists.RemoveAll(x => x.UserId == id);
                }
                if (user == null)
                    wishlists.RemoveAll(x => x.UserId == id);
            }

            tier1.AddRange(wishlists.Where(x => x.Waifu.Tier == 1).Select(x => x.Waifu));
            tier2.AddRange(wishlists.Where(x => x.Waifu.Tier == 2).Select(x => x.Waifu));
            tier3.AddRange(wishlists.Where(x => x.Waifu.Tier == 3).Select(x => x.Waifu));

            ShopWaifu item = null;
            List<ShopWaifu> waifus = new List<ShopWaifu>();
            var rnd = new Random();
            int r = 0;

            for (int k = 0; k < pages; k++)
            {
                // LIMITED WAIFU
                for (int i = 0; i < limitedamount; i++)
                {
                    r = rnd.Next(0, tier1.Count);
                    item = new ShopWaifu { Waifu = tier1.ElementAt(r), Discount = GenerateDiscount(), Limited = 1, BoughtBy = 0 };
                    waifus.Add(item);
                    tier1.RemoveAll(x => x.Name.Equals(tier1[r].Name));
                }

                // TIER 0 AND 1 WAIFUS
                for (int i = 0; i < t1amount; i++)
                {
                    r = rnd.Next(0, tier1.Count + tier0.Count);

                    if (r < tier1.Count)
                    {
                        item = new ShopWaifu { Waifu = tier1.ElementAt(r), Limited = -1, BoughtBy = 0 };
                        tier1.RemoveAll(x => x.Name.Equals(tier1[r].Name));
                    }
                    else
                    {
                        r -= tier1.Count;
                        item = new ShopWaifu { Waifu = tier0[r], Limited = -1, BoughtBy = 0 };
                        tier0.RemoveAll(x => x.Name.Equals(tier0[r].Name));
                    }

                    waifus.Add(item);
                }

                // TIER 2 WAIFUS
                for (int i = 0; i < t2amount; i++)
                {
                    r = rnd.Next(0, tier2.Count);
                    item = new ShopWaifu { Waifu = tier2.ElementAt(r), Limited = -1, BoughtBy = 0 };
                    waifus.Add(item);
                    tier2.RemoveAll(x => x.Name.Equals(tier2[r].Name));
                }

                // TIER 3 WAIFUS
                for (int i = 0; i < t3amount; i++)
                {
                    r = rnd.Next(0, tier3.Count);
                    item = new ShopWaifu { Waifu = tier3.ElementAt(r), Limited = -1, BoughtBy = 0 };
                    waifus.Add(item);
                    tier3.RemoveAll(x => x.Name.Equals(tier3[r].Name));
                }
            }

            return waifus;
        }
Пример #22
0
        public async Task ModShopAddWaifu([Remainder] string name)
        {
            var prefix = Program.GetPrefix(Context);

            if (!PremiumDb.IsPremium(Context.Guild.Id, ProType.GuildPlus))
            {
                await Context.Channel.SendMessageAsync(embed : new EmbedBuilderPrepared(Context.User)
                                                       .WithDescription($"*~ This command requires Pro Guild+ ~*")
                                                       .WithFooter($"`{prefix}pro`")
                                                       .Build());

                return;
            }

            var shop = await WaifuUtil.GetShop(Context.Guild.Id, ShopType.Mod);

            var waifus = shop.ShopWaifus.Select(x => x.Waifu);

            var waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(name), this);

            if (waifu == null)
            {
                return;
            }

            if (waifu.Tier < 1 || waifu.Tier > 3)
            {
                await Context.Channel.SendMessageAsync(embed : new EmbedBuilderPrepared(Context.User)
                                                       .WithDescription($"*~ You can only add Tier 1-3 waifus ~*")
                                                       .Build());

                return;
            }
            if (shop.ShopWaifus.Count >= 15)
            {
                await Context.Channel.SendMessageAsync(embed : new EmbedBuilderPrepared(Context.User)
                                                       .WithDescription($"*~ The Mod Shop is limited to 15 waifus. `{prefix}msrw` to remove ~*")
                                                       .Build());

                return;
            }
            if (waifus.Any(x => x.Name.Equals(waifu.Name)))
            {
                await Context.Channel.SendMessageAsync(embed : new EmbedBuilderPrepared(Context.User)
                                                       .WithDescription($"*~ **{waifu.Name}** is already in the mod shop ~*")
                                                       .Build());

                return;
            }

            await WaifuShopDb.UpdateItem(new ShopWaifu
            {
                Discount  = 0,
                Limited   = -1,
                WaifuShop = shop,
                Waifu     = waifu
            });

            await Context.Channel.SendMessageAsync($"Added **{waifu.Name}** to the Mod Shop", embed : WaifuUtil.WaifuEmbedBuilder(waifu).Build());

            return;
        }
Пример #23
0
        public async Task NewWaifu(string name, int tier, string url = null)
        {
            var exists = await WaifuDb.GetWaifu(name);

            if (exists != null)
            {
                await ReplyAsync($"**{exists.Name}** is already a waifu.");

                return;
            }

            await Context.Channel.TriggerTypingAsync();

            url ??= Context.Message.Attachments.FirstOrDefault()?.Url;

            if (url != null)
            {
                url = url.EndsWith(".gifv") ? url.Replace(".gifv", ".gif") : url;
                url = url.EndsWith(".mp4") ? url.Replace(".mp4", ".gif") : url;

                if (ImgurAPI.RateLimit.ClientRemaining < 15)
                {
                    await ReplyAsync("Not enough imgur credits to upload. Please try again later.");

                    return;
                }

                string albumId;
                if (!ImageDb.AlbumExists("Waifus"))
                {
                    albumId = (await ImgurAPI.CreateAlbumAsync("Waifus")).Id;
                    await ImageDb.CreateAlbum("Waifus", albumId);
                }
                else
                {
                    albumId = ImageDb.GetAlbum("Waifus").AlbumId;
                }

                var iImage = await ImgurAPI.UploadImageAsync(url, albumId, null, name);

                url = iImage.Link;
            }

            var waifu = new Waifu {
                Name = name, Tier = tier, ImageUrl = url, Description = null, LongName = null
            };
            await WaifuUtil.UploadWaifuImage(waifu, Context.Channel);

            if (await WaifuDb.AddWaifu(waifu) > 0)
            {
                await Context.Channel.SendMessageAsync($"{name} added.");
            }
            else
            {
                await Context.Channel.SendMessageAsync($"Failed to add {name}");
            }

            await Context.Channel.TriggerTypingAsync();

            await WaifuUtil.FindAndUpdateWaifuImageSource(waifu, Context.Channel);
        }
Пример #24
0
        public async Task <WaifuDetailedView> Get([FromRoute] string name)
        {
            var res = await WaifuDb.GetWaifu(name);

            return(res.ToView());
        }
Пример #25
0
        public async Task WaifuImage(string name, string url = null)
        {
            var waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(name, true), this);

            if (waifu == null)
            {
                return;
            }

            await Context.Channel.TriggerTypingAsync();

            url ??= Context.Message.Attachments.FirstOrDefault()?.Url;

            if (url == null)
            {
                await Context.Channel.SendMessageAsync("Can't get your attachment, there probably isn't one. *Heh, dummy...*");

                return;
            }

            url = url.EndsWith(".gifv") ? url.Replace(".gifv", ".gif") : url;
            url = url.EndsWith(".mp4") ? url.Replace(".mp4", ".gif") : url;

            if (ImgurAPI.RateLimit.ClientRemaining < 15)
            {
                await ReplyAsync("Not enough imgur credits to upload. Please try again later.");

                return;
            }

            string albumId;

            if (!ImageDb.AlbumExists("Waifus"))
            {
                albumId = (await ImgurAPI.CreateAlbumAsync("Waifus")).Id;
                await ImageDb.CreateAlbum("Waifus", albumId);
            }
            else
            {
                albumId = ImageDb.GetAlbum("Waifus").AlbumId;
            }

            var iImage = await ImgurAPI.UploadImageAsync(url, albumId, null, name);

            string old = waifu.ImageUrl;

            waifu.ImageUrl = iImage.Link;
            await WaifuUtil.UploadWaifuImage(waifu, Context.Channel);

            if (await WaifuDb.UpdateWaifu(waifu) > 0)
            {
                await SendWaifuUpdatedMessage(waifu, "ImageUrl", old, waifu.ImageUrl);
            }
            else
            {
                await Context.Channel.SendMessageAsync($":x: Failed to update {name}");
            }

            await Context.Channel.TriggerTypingAsync();

            await WaifuUtil.FindAndUpdateWaifuImageSource(waifu, Context.Channel);
        }
Пример #26
0
        public async Task NewWaifuAutocomplete(string name, long malId, string url = null)
        {
            var exists = await WaifuDb.GetWaifu(name);

            if (exists != null)
            {
                await ReplyAsync($"**{exists.Name}** is already a waifu.");

                return;
            }

            await Context.Channel.TriggerTypingAsync();

            url ??= Context.Message.Attachments.FirstOrDefault()?.Url;

            if (url != null)
            {
                url = url.EndsWith(".gifv") ? url.Replace(".gifv", ".gif") : url;
                url = url.EndsWith(".mp4") ? url.Replace(".mp4", ".gif") : url;

                if (ImgurAPI.RateLimit.ClientRemaining < 15)
                {
                    await ReplyAsync("Not enough imgur credits to upload. Please try again later.");

                    return;
                }

                string albumId;
                if (!ImageDb.AlbumExists("Waifus"))
                {
                    albumId = (await ImgurAPI.CreateAlbumAsync("Waifus")).Id;
                    await ImageDb.CreateAlbum("Waifus", albumId);
                }
                else
                {
                    albumId = ImageDb.GetAlbum("Waifus").AlbumId;
                }

                var iImage = await ImgurAPI.UploadImageAsync(url, albumId, null, name);

                url = iImage.Link;
            }

            var waifu = new Waifu {
                Name = name, Tier = 404, ImageUrl = url, Description = null, LongName = null
            };
            await WaifuUtil.UploadWaifuImage(waifu, Context.Channel);

            var mal = await WebUtil.GetWaifu(malId);

            waifu.LongName = $"{mal.Name} ({mal.NameKanji})";
            var    about = mal.About;
            var    lines = about.Split('\n');
            string desc  = "";

            foreach (var line in lines)
            {
                if (line.Split(' ')[0].EndsWith(':'))
                {
                    continue;
                }
                if (line.StartsWith('('))
                {
                    continue;
                }

                var l = Regex.Replace(line, @"\t|\n|\r|\\n|\\t|\\r", "");
                if (l != "")
                {
                    desc += l + "\n\n";
                }
            }
            waifu.Description = desc;
            waifu.Source      = mal.Animeography.FirstOrDefault() == null ? "" : mal.Animeography.FirstOrDefault().Name;
            try
            {
                waifu.Tier = WaifuUtil.FavoritesToTier(mal.MemberFavorites.Value);
            } catch { }

            if (waifu.Tier == 0)
            {
                waifu.Tier = 3;
                await Context.Channel.SendMessageAsync($"Not enough favorites! Are you sure you wish to create this waifu? Remove - `!dw {waifu.Name}`");
            }

            if (await WaifuDb.AddWaifu(waifu) > 0)
            {
                await Context.Channel.SendMessageAsync
                (
                    $"Autocompleted **{waifu.Name}**. Has **{mal.MemberFavorites}** favorites.",
                    embed : WaifuUtil.WaifuEmbedBuilder(waifu, Context).Build()
                );

                await WaifuDb.AddMalWaifu(new MalWaifu
                {
                    MalId        = malId,
                    WaifuName    = waifu.Name,
                    LastUpdated  = DateTime.Now,
                    MalConfirmed = true
                });
            }
            else
            {
                await Context.Channel.SendMessageAsync("Rip");
            }

            await Context.Channel.TriggerTypingAsync();

            await WaifuUtil.FindAndUpdateWaifuImageSource(waifu, Context.Channel);
        }