Exemple #1
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);
        }
Exemple #2
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);
        }
Exemple #3
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);
        }
Exemple #4
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));
        }