示例#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 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());
        }
示例#3
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());
        }
示例#4
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;
        }
示例#5
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);
            }
        }
示例#6
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());
        }
示例#7
0
        public static EmbedBuilder TeamEmbed(SocketRole teamRole, SocketRole leaderRole)
        {
            var eb = new EmbedBuilder();

            List <SocketGuildUser> leaderUsers = new List <SocketGuildUser>(leaderRole.Members);
            List <SocketGuildUser> teamUsers   = new List <SocketGuildUser>(teamRole.Members);

            teamUsers.RemoveAll(x => leaderUsers.Any(y => y.Equals(x)));

            int totalToasties   = 0;
            int totalWaifus     = 0;
            int totalWaifuValue = 0;

            string memberList = "";

            foreach (var x in teamUsers)
            {
                memberList += $"\n`{x.Username}`";

                totalToasties += BalanceDb.GetToasties(x.Id, x.Guild.Id);
                var waifus = UserInventoryDb.GetWaifus(x.Id, x.Guild.Id);
                totalWaifus     += waifus.Count;
                totalWaifuValue += WaifuUtil.WaifuValue(waifus);
            }

            string leaderList = "";

            foreach (var x in leaderUsers)
            {
                leaderList += $"\n`{x.Username}`";

                totalToasties += BalanceDb.GetToasties(x.Id, x.Guild.Id);
                var waifus = UserInventoryDb.GetWaifus(x.Id, x.Guild.Id);
                totalWaifus     += waifus.Count;
                totalWaifuValue += WaifuUtil.WaifuValue(waifus);
            }

            eb.WithDescription($"Total Toasties: {totalToasties.ToString("n0")} <:toastie3:454441133876183060>\n" +
                               $"Total Waifus: {totalWaifus.ToString("n0")} :two_hearts:\n" +
                               $"Waifu Value: {totalWaifuValue.ToString("n0")} <:toastie3:454441133876183060>");
            eb.AddField($":shield: Members - {teamUsers.Count}", memberList == "" ? "-" : memberList, true);
            eb.AddField($":crown: Leaders - {leaderUsers.Count}", leaderList == "" ? "-" : leaderList, true);
            eb.WithColor(BasicUtil.RandomColor());
            eb.WithTitle(teamRole.Name);
            return(eb);
        }
示例#8
0
        public static EmbedBuilder WaifusEmbed(SocketGuildUser user)
        {
            var eb = new EmbedBuilder();

            eb.WithAuthor(user);
            var waifus = UserInventoryDb.GetWaifus(user.Id, user.Guild.Id).OrderBy(x => x.Source).ThenBy(x => x.Name);

            if (waifus.Any())
            {
                string wstr = "";
                foreach (var x in waifus)
                {
                    string row = String.Format("**{0}** - *{1}*", x.Name, x.Source);
                    if (row.Length > 47)
                    {
                        row = row.Substring(0, 43) + "...";
                    }
                    wstr += row + "\n";
                }
                eb.AddField("Waifus :revolving_hearts:", wstr);

                var waifu = FeaturedWaifuDb.GetFeaturedWaifu(user.Id, user.Guild.Id);
                if (waifu != null)
                {
                    eb.WithThumbnailUrl(waifu.HostImageUrl);
                }
                else
                {
                    eb.WithThumbnailUrl(user.GetAvatarUrl());
                }

                eb.WithDescription($"Open in [browser](https://namiko.moe/Guild/{user.Guild.Id}/{user.Id})");
            }
            else
            {
                string desc = "You find yourself in a strange place. You are all alone in the darkness. You have no waifus, no love, no purpose.\n\nBut perhaps all is not lost?\n\n"
                              + $"*A pillar of light reveals strange texts*\n"
                              + $"```{Program.GetPrefix(user)}lootbox\n{Program.GetPrefix(user)}daily\n{Program.GetPrefix(user)}weekly\n{Program.GetPrefix(user)}waifushop```";
                eb.WithDescription(desc);
            }

            eb.WithColor(ProfileDb.GetHex(out string colour, user.Id) ? (Discord.Color)HexToColor(colour) : BasicUtil.RandomColor());
            return(eb);
        }
示例#9
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);
        }
示例#10
0
        public async Task Waifus([Remainder] IUser user = null)
        {
            user ??= Context.User;

            var waifus = UserInventoryDb.GetWaifus(user.Id, Context.Guild.Id);

            if (waifus.Count <= 21)
            {
                await Context.Channel.SendMessageAsync("", false, UserUtil.WaifusEmbed((SocketGuildUser)user).Build());

                return;
            }

            var ordwaifus = waifus.OrderBy(x => x.Source).ThenBy(x => x.Name);
            var msg       = new CustomPaginatedMessage();

            var author = new EmbedAuthorBuilder()
            {
                IconUrl = user.GetAvatarUrl(),
                Name    = user.ToString()
            };

            msg.Author = author;

            msg.ThumbnailUrl = FeaturedWaifuDb.GetFeaturedWaifu(user.Id, Context.Guild.Id).HostImageUrl;
            var pages = CustomPaginatedMessage.PagesArray(ordwaifus, 15, (x) => String.Format("**{0}** - *{1}*\n", x.Name, x.Source.Length > 33 ? x.Source.Substring(0, 33) + "..." : x.Source), false);

            msg.Fields = new List <FieldPages> {
                new FieldPages {
                    Title = "Waifus :revolving_hearts:", Pages = pages
                }
            };
            msg.Pages = new List <string> {
                $"Open in [browser](https://namiko.moe/Guild/{Context.Guild.Id}/{user.Id})"
            };

            await PagedReplyAsync(msg);
        }
示例#11
0
        public async Task WaifuLeaderboard([Remainder] string str = "")
        {
            var AllWaifus = await UserInventoryDb.GetAllWaifuItems(Context.Guild.Id);

            var users = new Dictionary <SocketUser, int>();

            foreach (var x in AllWaifus)
            {
                var user = Context.Guild.GetUser(x.UserId);
                if (user != null)
                {
                    if (!users.ContainsKey(user))
                    {
                        users.Add(user, WaifuUtil.WaifuValue(AllWaifus.Where(x => x.UserId == user.Id).Select(x => x.Waifu)));
                    }
                }
            }

            var ordUsers = users.OrderByDescending(x => x.Value);

            var msg = new CustomPaginatedMessage();

            msg.Title = "User Leaderboards";
            var fields = new List <FieldPages>
            {
                new FieldPages
                {
                    Title = "Waifu Value <:toastie3:454441133876183060>",
                    Pages = CustomPaginatedMessage.PagesArray(ordUsers, 10, (x) => $"{x.Key.Mention} - {x.Value}\n")
                }
            };

            msg.Fields = fields;

            await PagedReplyAsync(msg);
        }
示例#12
0
        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();
            });
        }
示例#13
0
        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();
            });
        }
示例#14
0
        // Embeds
        //Embed Method: profile
        public static async Task <EmbedBuilder> ProfileEmbed(SocketGuildUser user)
        {
            var eb = new EmbedBuilder();

            string name = user.Username;

            var role = RoleUtil.GetMemberRole(user.Guild, user) ?? RoleUtil.GetLeaderRole(user.Guild, user);

            if (role != null)
            {
                var team = TeamDb.TeamByMember(role.Id) ?? TeamDb.TeamByLeader(role.Id);
                if (team != null)
                {
                    role = user.Roles.FirstOrDefault(x => x.Id == team.LeaderRoleId);
                    if (role == null)
                    {
                        role = user.Roles.FirstOrDefault(x => x.Id == team.MemberRoleId);
                    }

                    name += $" | {role.Name}";
                }
            }

            if (PremiumDb.IsPremium(user.Id, ProType.ProPlus))
            {
                name += " | Pro+ 🌟";
            }
            else if (PremiumDb.IsPremium(user.Id, ProType.Pro))
            {
                name += " | Pro ⭐";
            }
            eb.WithAuthor(name, user.GetAvatarUrl(), $"https://namiko.moe/Guild/{user.Guild.Id}/{user.Id}");

            var waifus     = UserInventoryDb.GetWaifus(user.Id, user.Guild.Id);
            int waifucount = waifus.Count();
            int waifuprice = WaifuUtil.WaifuValue(waifus);

            var  daily   = DailyDb.GetDaily(user.Id, user.Guild.Id);
            long timeNow = DateTimeOffset.Now.ToUnixTimeMilliseconds();

            string text = "";

            text += $"Amount: {BalanceDb.GetToasties(user.Id, user.Guild.Id).ToString("n0")}\n" +
                    $"Daily: {(daily == null ? "0" : ((daily.Date + 172800000) < timeNow ? "0" : daily.Streak.ToString()))}\n" +
                    $"Boxes Opened: {ProfileDb.GetLootboxOpenedAmount(user.Id)}\n";
            eb.AddField("Toasties <:toastie3:454441133876183060>", text, true);

            text = $"Amount: {waifucount}\n" +
                   $"Value: {waifuprice.ToString("n0")}\n";
            foreach (var x in MarriageDb.GetMarriages(user.Id, user.Guild.Id))
            {
                try
                {
                    if (!text.Contains("Married: "))
                    {
                        text += "Married: ";
                    }
                    text += $"{BasicUtil.IdToMention(GetWifeId(x, user.Id))}\n";
                } catch { }
            }
            eb.AddField("Waifus :two_hearts:", text, true);

            var waifu = FeaturedWaifuDb.GetFeaturedWaifu(user.Id, user.Guild.Id);

            if (waifu != null)
            {
                eb.WithImageUrl(waifu.HostImageUrl);
                eb.AddField("Featured Waifu <:MiaHug:536580304018735135>", $"**{waifu.Name}** - *{waifu.Source}*");
            }

            var    rep    = ProfileDb.GetRepAmount(user.Id);
            string footer = $"Votes: {await VoteDb.VoteCount(user.Id)} • ";

            footer += $"Rep: {rep} • ";
            // Activities require guildpresence
            //footer += $"Status: '{user.Status}'";
            //var activity = user.Activities.FirstOrDefault();
            //if (activity != null)
            //    footer += $", {activity.Type}: '{activity.Name}'";
            eb.WithFooter(footer);

            //quote
            string quote = ProfileDb.GetQuote(user.Id);

            if (!String.IsNullOrEmpty(quote) & !WebUtil.IsValidUrl(quote))
            {
                eb.WithDescription(quote);
            }

            //image
            string image = ProfileDb.GetImage(user.Id);

            if (WebUtil.IsValidUrl(image))
            {
                eb.WithThumbnailUrl(image);
            }

            eb.Color = ProfileDb.GetHex(out string colour, user.Id)? (Discord.Color)HexToColor(colour) : BasicUtil.RandomColor();
            return(eb);
        }
示例#15
0
        public async Task <IActionResult> GetGuildUser([FromRoute] ulong guildId, [FromRoute] ulong userId)
        {
            var client = await HttpContext.GetBotClient();

            Task <RestGuildUser> currentUser = client.GetGuildUserAsync(guildId, HttpContext.GetUserId());
            Task <RestGuildUser> searchUser  = client.GetGuildUserAsync(guildId, userId);
            var guild = client.GetGuildAsync(guildId);
            var tasks = new List <Task>();

            try
            {
                tasks.Add(currentUser);
                tasks.Add(searchUser);
                tasks.Add(guild);
                await Task.WhenAll(tasks);
            }
            catch (HttpException)
            {
                return(StatusCode(412, "Bot not in guild"));
            }
            if (currentUser.Result == null)
            {
                return(StatusCode(403, "Unauthorized"));
            }
            if (searchUser.Result == null)
            {
                return(StatusCode(404, "No user in guild"));
            }

            var profile = await ProfileDb.GetProfile(searchUser.Result.Id);

            var bal = await BalanceDb.GetToastiesAsync(userId, guildId);

            var dailyRes = await DailyDb.GetDailyAsync(userId, guildId);

            var daily  = dailyRes == null ? 0 : dailyRes.Streak;
            var waifus = (await UserInventoryDb.GetWaifusAsync(userId, guildId)).OrderBy(x => x.Source).ThenBy(x => x.Name).ToView();
            var waifu  = FeaturedWaifuDb.GetFeaturedWaifu(userId, guildId).ToView();

            var user = new GuildUserView
            {
                AvatarUrl       = searchUser.Result.GetAvatarUrl(size: 256),
                Id              = searchUser.Result.Id.ToString(),
                Name            = searchUser.Result.Username,
                Discriminator   = searchUser.Result.Discriminator,
                ImageUrl        = profile.Image,
                Quote           = profile.Quote.CleanQuote(),
                LootboxesOpened = profile.LootboxesOpened,
                Rep             = profile.Rep,
                Balance         = bal,
                Daily           = daily,
                Waifus          = waifus,
                JoinedAt        = searchUser.Result.JoinedAt,
                Waifu           = waifu,
                Guild           = new GuildSummaryView
                {
                    ImageUrl = guild.Result.IconUrl,
                    Id       = guild.Result.Id.ToString(),
                    Name     = guild.Result.Name
                }
            };

            return(Ok(user));
        }
示例#16
0
        public static async Task <EmbedBuilder> ServerInfo(SocketGuild guild)
        {
            var eb = new EmbedBuilder();

            string name = guild.Name;

            if (PremiumDb.IsPremium(guild.Id, ProType.GuildPlus))
            {
                name += " | T1 Guild 🌟";
            }
            else if (PremiumDb.IsPremium(guild.Id, ProType.Guild))
            {
                name += " | T2 Guild ⭐";
            }
            eb.WithAuthor(name, guild.IconUrl, LinkHelper.GetRedirectUrl(LinkHelper.Patreon, "Patreon", "cmd-embed-info"));

            var toasties = (await BalanceDb.GetAllToastiesRaw(guild.Id)).OrderByDescending(x => x.Amount).ToList();
            var waifus   = await UserInventoryDb.GetAllWaifuItems(guild.Id);

            string field = "";

            field += $"Total toasties: **{toasties.Sum(x => (long)x.Amount).ToString("n0")}**\n";
            SocketGuildUser user = null;
            int             i    = 0;

            while (i < toasties.Count && (user == null || user.IsBot))
            {
                user = guild.GetUser(toasties[i++].UserId);
            }
            if (user != null)
            {
                field += $"Richest user: {user.Mention} - **{toasties.FirstOrDefault(x => x.UserId == user.Id).Amount.ToString("n0")}**\n";
            }

            var bank = toasties.FirstOrDefault(x => x.UserId == Program.GetClient().CurrentUser.Id);

            field += $"Bank balance: **{(bank == null ? "0" : bank.Amount.ToString("n0"))}**\n";
            eb.AddField("Toasties <:toastie3:454441133876183060>", field);

            field  = "";
            field += $"Total waifus: **{waifus.Count.ToString("n0")}**\n";
            field += $"Total waifu value: **{waifus.Sum(x => Convert.ToInt64(WaifuUtil.GetPrice(x.Waifu.Tier, 0))).ToString("n0")}**\n";
            var groupedwaifus = waifus.GroupBy(x => x.UserId).OrderByDescending(x => x.Count()).ToList();
            IGrouping <ulong, UserInventory> most = null;

            user = null;
            i    = 0;
            while (i < groupedwaifus.Count && (user == null || user.IsBot))
            {
                most = groupedwaifus[i];
                user = guild.GetUser(groupedwaifus[i++].Key);
            }
            if (most != null && user != null)
            {
                field += $"Most waifus: {user.Mention} - **{most.Count().ToString("n0")}**\n";
            }

            groupedwaifus = groupedwaifus.OrderByDescending(x => x.Sum(y => WaifuUtil.GetPrice(y.Waifu.Tier, 0))).ToList();
            most          = null;
            user          = null;
            i             = 0;
            while (i < groupedwaifus.Count && (user == null || user.IsBot))
            {
                most = groupedwaifus[i];
                user = guild.GetUser(groupedwaifus[i++].Key);
            }
            if (most != null && user != null)
            {
                field += $"Highest value: {user.Mention} - **{most.Sum(y => WaifuUtil.GetPrice(y.Waifu.Tier, 0)).ToString("n0")}**\n";
            }
            eb.AddField("Waifus :two_hearts:", field);

            eb.WithColor(BasicUtil.RandomColor());
            eb.WithFooter("To be expanded");
            eb.WithThumbnailUrl(guild.IconUrl);
            return(eb);
        }