コード例 #1
0
        public static EmbedBuilder MarriagesEmbed(IUser user, SocketGuild guild)
        {
            //embed basics
            string          partners  = "";
            List <Marriage> marriages = MarriageDb.GetMarriages(user.Id, guild.Id);

            foreach (Marriage marriage in marriages)
            {
                partners += $"{BasicUtil.IdToMention(GetWifeId(marriage, user.Id))} :revolving_hearts: {marriage.Date.ToString("yyyy/MM/dd")}\n";
            }

            //embed
            EmbedBuilder embed = new EmbedBuilder();

            embed.WithColor(ProfileDb.GetHex(out string colour, user.Id) ? (Discord.Color)UserUtil.HexToColor(colour) : BasicUtil.RandomColor());
            if (!String.IsNullOrEmpty(partners))
            {
                embed.AddField("Married To", partners, true);
                try
                {
                    embed.WithImageUrl(Program.GetClient().GetUser(GetWifeId(marriages[0], user.Id)).GetAvatarUrl());
                } catch { }
            }
            else
            {
                embed.WithDescription("You are not Married.");
            }
            embed.WithAuthor(user);
            return(embed);
        }
コード例 #2
0
        public async Task Decline([Remainder] string str = "")
        {
            //common variables
            IUser        user = Context.User;
            EmbedBuilder eb   = new EmbedBuilder();

            eb.WithAuthor(user);
            eb.WithColor(ProfileDb.GetHex(out string colour, user.Id) ? (Discord.Color)UserUtil.HexToColor(colour) : BasicUtil.RandomColor());

            var proposals = MarriageDb.GetProposalsReceived(user.Id, Context.Guild.Id);

            proposals.AddRange(MarriageDb.GetProposalsSent(user.Id, Context.Guild.Id));
            var proposal = await UserUtil.SelectMarriage(proposals, this);

            if (proposal == null)
            {
                eb.WithDescription("~ You have no proposals ~");
                await Context.Channel.SendMessageAsync($"", false, eb.Build());

                return;
            }

            ulong wife = UserUtil.GetWifeId(proposal, user.Id);
            // Swagness
            //creating decline action
            var decline = new DialogueBoxOption
            {
                Action = async(IUserMessage message) => {
                    await MarriageDb.DeleteMarriageOrProposal(proposal);

                    //embed
                    eb.WithAuthor(user);
                    eb.WithDescription($"You declined the proposal.\nBetter luck next time **{ BasicUtil.IdToMention(wife) }**.");
                    await message.ModifyAsync(x => x.Embed = eb.Build());

                    //execution condition
                },
                After = OnExecute.RemoveReactions
            };

            //creating cancel
            var cancel = new DialogueBoxOption {
                After = OnExecute.Delete
            };

            //making dialog embed
            var dia = new DialogueBox();

            dia.Options.Add(Emote.Parse("<:TickYes:577838859107303424>"), decline);
            dia.Options.Add(Emote.Parse("<:TickNo:577838859077943306>"), cancel);
            dia.Timeout = new TimeSpan(0, 1, 0);
            dia.Embed   = new EmbedBuilderPrepared(user)
                          .WithDescription($"Are you sure you wish to Decline **{ BasicUtil.IdToMention(wife) }**?").Build();

            //
            await DialogueReplyAsync(dia);
        }
コード例 #3
0
        public async Task Divorce([Remainder] string str = "")
        {
            //common variables
            IUser        user = Context.User;
            EmbedBuilder eb   = new EmbedBuilder();

            Discord.Color userColour = ProfileDb.GetHex(out string colour, user.Id) ? (Discord.Color)UserUtil.HexToColor(colour) : BasicUtil.RandomColor();
            eb.WithColor(userColour);
            eb.WithAuthor(user);

            var marriages = MarriageDb.GetMarriages(user.Id, Context.Guild.Id);
            var marriage  = await UserUtil.SelectMarriage(marriages, this);

            if (marriage == null)
            {
                eb.WithDescription("~ You are not married ~");
                await Context.Channel.SendMessageAsync($"", false, eb.Build());

                return;
            }

            ulong wife = UserUtil.GetWifeId(marriage, user.Id);
            //
            //creating divorce action
            var divorce = new DialogueBoxOption {
                Action = async(IUserMessage message) => {
                    await MarriageDb.DeleteMarriageOrProposal(marriage);

                    await message.ModifyAsync((x) => x.Embed = eb.WithDescription($"You divorced **{ BasicUtil.IdToMention(wife) }**.\n*~ May you both find happiness elsewhere ~*").Build());

                    //execution condition
                }, After = OnExecute.RemoveReactions
            };

            //creating cancel
            var cancel = new DialogueBoxOption {
                After = OnExecute.Delete
            };

            //making dialog embed
            var dia = new DialogueBox();

            dia.Options.Add(Emote.Parse("<:TickYes:577838859107303424>"), divorce);
            dia.Options.Add(Emote.Parse("<:TickNo:577838859077943306>"), cancel);
            dia.Timeout = new TimeSpan(0, 1, 0);
            dia.Embed   = new EmbedBuilderPrepared(user)
                          .WithColor(userColour)
                          .WithDescription($"Are you sure you wish to Divorce **{ BasicUtil.IdToMention(wife) }**?").Build();

            //
            await DialogueReplyAsync(dia);
        }
コード例 #4
0
        public static EmbedBuilder ListMarriageEmbed(List <Marriage> marriages, IUser author)
        {
            var    eb   = new EmbedBuilderPrepared(author);
            string list = "";
            int    i    = 1;

            foreach (var x in marriages)
            {
                list += $"`#{i++}` {BasicUtil.IdToMention(GetWifeId(x, author.Id))}\n";
            }
            eb.AddField("User List <:MiaHug:536580304018735135>", list);
            return(eb);
        }
コード例 #5
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);
        }