Esempio n. 1
0
        public async Task SetPersonalQuote([Remainder] string quote = null)
        {
            //null me babi
            if (quote == null)
            {
                await ProfileDb.SetQuote(Context.User.Id, null);

                await Context.Channel.SendMessageAsync("Quote removed.");

                return;
            }

            //length check
            if (quote.Length > Constants.quoteCap)
            {
                await Context.Channel.SendMessageAsync($"Quotes have a { Constants.quoteCap } character limit. {quote.Length}/{Constants.quoteCap}");

                return;
            }

            //setting quote + getting embed & quote
            await ProfileDb.SetQuote(Context.User.Id, quote);

            await Context.Channel.SendMessageAsync("Quote set!", false, UserUtil.QuoteEmbed(Context.User).Build());
        }
Esempio n. 2
0
 public async Task Profile([Remainder] IUser user = null)
 {
     if (user == null)
     {
         user = Context.User;
     }
     await Context.Channel.SendMessageAsync("", false, (await UserUtil.ProfileEmbed((SocketGuildUser)user)).Build());
 }
Esempio n. 3
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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
        public async Task SetPersonalColour(string shade = "", string colour = "", [Remainder] string str = "")
        {
            //
            //way to set it back to default
            if (shade.Equals(""))
            {
                await ProfileDb.HexDefault(Context.User.Id);

                //sending embed + exception & error confermations
                EmbedBuilder embed = UserUtil.SetColourEmbed(Context.User);
                embed.WithDescription($"{ Context.User.Username } set colour to **Default**");
                await Context.Channel.SendMessageAsync("", false, embed.Build());

                return;


                //if no shade specified but colour value exists
            }
            if (colour.Equals(""))
            {
                colour = shade;
            }



            //
            //setting start values & checking for possible name or hex value
            System.Drawing.Color color = System.Drawing.Color.White;
            if (UserUtil.GetNamedColour(ref color, colour, shade) || UserUtil.GetHexColour(ref color, colour))
            {
                //toastie + saving hex colour
                try {
                    await BalanceDb.AddToasties(Context.User.Id, -Constants.colour, Context.Guild.Id);

                    await ProfileDb.SetHex(color, Context.User.Id);

                    await Context.Channel.SendMessageAsync("", false, UserUtil.SetColourEmbed(Context.User).Build());
                } catch (Exception ex) { await Context.Channel.SendMessageAsync(ex.Message); }
            }
        }
Esempio n. 6
0
        public async Task DisplayPersonalQuote(IUser user = null, [Remainder] string str = "")
        {
            //variables
            EmbedBuilder embed;
            bool         isMe = false;

            if (user == null)
            {
                user = Context.User;
                isMe = true;
            }

            //
            IReadOnlyCollection <SocketUser> users = Context.Message.MentionedUsers;

            if (users != null && users.Count > 1)
            {
                embed = UserUtil.StitchedQuoteEmbed(users);
                if (embed == null)
                {
                    await Context.Channel.SendMessageAsync("No one had a proper \"Quote\" qq");
                }
                else
                {
                    await Context.Channel.SendMessageAsync("", false, embed.Build());
                }
                return;
            }

            //checking quote
            embed = UserUtil.QuoteEmbed(user);
            if (embed == null)
            {
                await Context.Channel.SendMessageAsync($"{(isMe? "You don't" : $"{ user.Username } doesn't") } have an image or a quote. Set one with `sq` and `si` commands.");

                return;

                //sending quote
            }
Esempio n. 7
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);
        }
Esempio n. 8
0
        public async Task SetPersonalImage([Remainder] string image = null)
        {
            image ??= Context.Message.Attachments.FirstOrDefault()?.Url;

            //to delete image
            if (image == null)
            {
                await ProfileDb.SetImage(Context.User.Id, null);

                await Context.Channel.SendMessageAsync("Image removed.");

                return;
            }

            //url check
            if (!WebUtil.IsValidUrl(image))
            {
                await Context.Channel.SendMessageAsync("This URL is just like you... Invalid.");

                return;
            }

            //image validity check
            if (!WebUtil.IsImageUrl(image))
            {
                await Context.Channel.SendMessageAsync("This URL is not an image, what do you want me to do with it?");

                return;
            }

            //building embed
            await ProfileDb.SetImage(Context.User.Id, image);

            EmbedBuilder embed = UserUtil.QuoteEmbed(Context.User);
            await Context.Channel.SendMessageAsync("Image set!", false, embed.Build());
        }
Esempio n. 9
0
        public async Task Marriage(IUser wife = null, [Remainder] string str = "")
        {
            //commonly used variables + embed basics
            EmbedBuilder eb = new EmbedBuilder();

            eb.WithColor(ProfileDb.GetHex(out string colour, Context.User.Id) ? (Discord.Color)UserUtil.HexToColor(colour) : BasicUtil.RandomColor());
            ulong guildID = Context.Guild.Id;
            IUser user    = Context.User;

            eb.WithAuthor(user);

            // checks
            //making sure u cant do anything weird
            if (wife == null || wife == user || wife.IsBot)
            {
                eb.WithDescription($"You can't propose to { ((wife == null) ? "no one" : wife.IsBot ? "bots" : "yourself ") } unfortunately.");
                await Context.Channel.SendMessageAsync("", false, eb.Build());

                return;
            }

            if (MarriageDb.GetProposalsSent(Context.User.Id, Context.Guild.Id).Any(x => x.WifeId == wife.Id))
            {
                eb.WithAuthor(user);
                eb.WithDescription($"You have already proposed to **{wife}**.");
                await Context.Channel.SendMessageAsync($"", false, eb.Build());

                return;
            }

            if (MarriageDb.GetMarriages(user.Id, Context.Guild.Id).Any(x => x.WifeId == wife.Id || x.UserId == wife.Id))
            {
                eb.WithDescription($"You're already married to **{wife}**.");
                await Context.Channel.SendMessageAsync("", false, eb.Build());

                return;
            }

            //checking marriage status
            Marriage proposal = MarriageDb.GetMarriageOrProposal(wife.Id, user.Id, Context.Guild.Id);

            if (proposal == null)
            {
                await MarriageDb.Propose(user.Id, wife.Id, guildID);

                eb.WithAuthor(wife);
                eb.WithDescription($"**{ user.Mention }** has proposed to you.");
                eb.WithFooter($"`{Program.GetPrefix(Context)}marry [user]` or `{Program.GetPrefix(Context)}decline [user]`");
                await Context.Channel.SendMessageAsync($"", false, eb.Build());

                return;
            }

            //if already married

            //checking marriage cap
            if (MarriageDb.GetMarriages(Context.User.Id, Context.Guild.Id).Count >= UserUtil.GetMarriageLimit(Context.User.Id) ||
                MarriageDb.GetMarriages(wife.Id, Context.Guild.Id).Count >= UserUtil.GetMarriageLimit(wife.Id))
            {
                eb.WithDescription($"One of you has reached the maximum number of marriages.");
                eb.WithFooter($"Limit can be increased to {Constants.ProMarriageLimit} or {Constants.ProPlusMarriageLimit} with Namiko Pro.");
                await Context.Channel.SendMessageAsync("", false, eb.Build());

                return;
            }

            // Marry em'
            //if the user has already proposed to you
            proposal.IsMarried = true;
            proposal.Date      = System.DateTime.Now;
            await MarriageDb.UpdateMarriage(proposal);

            eb.WithDescription($"**Congratulations**! You and **{ wife }** are now married!");
            await Context.Channel.SendMessageAsync($"", false, eb.Build());
        }
Esempio n. 10
0
 public async Task Marriages([Remainder] IUser user = null)
 {
     await Context.Channel.SendMessageAsync("", false, UserUtil.MarriagesEmbed(user ?? Context.User, Context.Guild).Build());
 }
Esempio n. 11
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);
        }
Esempio n. 12
0
        public static EmbedBuilder ProposalsEmbed(IUser user, SocketGuild guild)
        {
            //embed basics
            EmbedBuilder embed = new EmbedBuilder();

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

            //proposals
            List <Marriage> sent     = MarriageDb.GetProposalsSent(user.Id, guild.Id);
            List <Marriage> received = MarriageDb.GetProposalsReceived(user.Id, guild.Id);

            //fields aggregation
            int    users = 1;
            string field1 = "", field2 = "";

            foreach (Marriage proposals in sent)
            {
                field1 += $"#{users++} {guild.GetUser(proposals.WifeId) }\n";
            }

            //
            foreach (Marriage proposals in received)
            {
                field2 += $"#{users++} {guild.GetUser(proposals.UserId) }\n";
            }

            //if this dude is #ForeverAlone
            if (String.IsNullOrEmpty(field1) && String.IsNullOrEmpty(field2))
            {
                embed.WithDescription("You have not sent or received any Proposals.");
            }

            //do columns, sent on the left received on the right (or some shit)
            if (!String.IsNullOrEmpty(field1))
            {
                embed.AddField("Proposals Sent :sparkling_heart:", field1, true);
            }
            if (!String.IsNullOrEmpty(field2))
            {
                embed.AddField("Proposals Received :sparkling_heart:", field2, true);
            }
            return(embed);
        }