예제 #1
0
        public async Task DailyA()
        {
            DateTime now        = DateTime.Now;
            var      userPf     = UserProfiles.GetAccount(Context.User);
            DateTime daily      = userPf.daily;
            int      difference = DateTime.Compare(daily, now);

            if ((userPf.daily.ToString() == "0001-01-01 00:00:00") || (daily.DayOfYear < now.DayOfYear && difference < 0 || difference >= 0))
            {
                userPf.daily   = DateTime.Now;
                userPf.Points += 200;
                UserProfiles.SaveProfiles();
                await Context.Channel.SendMessageAsync($":white_check_mark: {Context.User.Username}, you claimed 200 Nico Nii's!");
            }
            else
            {
                TimeSpan diff = now - daily; // This line compute the difference of time between the two dates

                // This line prevents "Your credits refresh in 00:18:57.0072170 !"
                TimeSpan di  = new TimeSpan(23 - diff.Hours, 60 - diff.Minutes, 60 - diff.Seconds);
                string   str = di.ToString(@"hh\:mm\:ss");

                await ReplyAsync($":negative_squared_cross_mark: {Context.User.Username}, You have already claimed your daily Nico Nii's~\n\nThey refresh in {di.Days} day(s) {di.Hours} hour(s) {di.Minutes} min(s) and {di.Seconds} second(s)!");
            }
        }
예제 #2
0
        public async Task Default(uint amount = 0)
        {
            var user = UserProfiles.GetAccount(Context.User);

            if (!user.IsRPS)
            {
                if (user.Points >= amount)
                {
                    var embed = new EmbedBuilder()
                                .WithColor(new Color(255, 73, 167))
                                .AddField("Let's play a game", "Choose between **rock**, **paper** or **scissors**.\n\n\"((≡|≡))_/ \_((≡|≡) )\"");
                    await ReplyAsync("", false, embed.Build());

                    if (amount > 0)
                    {
                        user.IsRPSGamble  = true;
                        user.GambleAmount = amount;
                        user.Points      -= amount;
                    }
                    user.IsRPS = true;
                    UserProfiles.SaveProfiles();
                }
                else
                {
                    await ReplyAsync($":negative_squared_cross_mark: {Context.User.Username}, you do not have enough Nico Nii's to play.");
                }
            }
            else
            {
                await ReplyAsync($":negative_squared_cross_mark: | {Context.User.Username}, you are already playing RPS!");
            }
        }
예제 #3
0
        public async Task DenyMarriageSlot()
        {
            var userPf = UserProfiles.GetAccount(Context.User); // You

            if (userPf.IsBuyingSlot)
            {
                userPf.IsBuyingSlot = false;
                UserProfiles.SaveProfiles();
                await ReplyAsync($"You canceled the transaction.");
            }
        }
예제 #4
0
        public async Task DivorceUser(SocketUser user)
        {
            var userPf       = UserProfiles.GetAccount(Context.User); // You
            var proposedUser = UserProfiles.GetAccount(user);         // Proposer

            if (proposedUser.Marriages.Contains(Context.User.Id) && userPf.Marriages.Contains(user.Id))
            {
                UserProfiles.DivorceUser(Context.User, user);

                await ReplyAsync($"{Context.User.Username} have divorced {user.Username}!");
            }
        }
예제 #5
0
        public async Task BuyMarriageSlot()
        {
            var    userPf = UserProfiles.GetAccount(Context.User); // You
            var    gp     = GuildProfiles.GetAccount(Context.Guild);
            string prefix = gp.CmdPrefix;

            var slots    = userPf.MarriageSlots;
            int currency = 0;

            switch (slots)
            {
            case 5:
                currency            = 2500;
                userPf.IsBuyingSlot = true;
                break;

            case 6:
                currency            = 4500;
                userPf.IsBuyingSlot = true;
                break;

            case 7:
                currency            = 6500;
                userPf.IsBuyingSlot = true;
                break;

            case 8:
                currency            = 8500;
                userPf.IsBuyingSlot = true;
                break;

            case 9:
                currency            = 10000;
                userPf.IsBuyingSlot = true;
                break;

            case 10:
                await ReplyAsync($"You can't buy anymore slots.");

                userPf.IsBuyingSlot = false;
                break;
            }

            if (userPf.IsBuyingSlot)
            {
                await ReplyAsync($"You can buy a marriage slot for {currency} Nico Nii's. Would you like to buy it?\n\n Type {prefix}buy slot yes or {prefix}buy slot no");
            }
            UserProfiles.SaveProfiles();
        }
예제 #6
0
        public async Task DeclineUserMarriage(SocketUser user)
        {
            var userPf = UserProfiles.GetAccount(Context.User);

            if (userPf.MarriageProposals.Contains(user.Id))
            {
                UserProfiles.DeclineMarriage(Context.User, user);

                await ReplyAsync($"You have declined {user.Username}'s marriage proposal.");
            }
            else
            {
                await ReplyAsync($"You have not proposed to {user.Username}!");
            }
        }
예제 #7
0
        public async Task AcceptUserMarriage(SocketUser user)
        {
            var userPf = UserProfiles.GetAccount(Context.User);

            if (userPf.MarriageProposals.Contains(user.Id))
            {
                UserProfiles.AcceptMarriage(Context.User, user);

                await ReplyAsync($":tada: Congrulations! You and {user.Username} are married!");
            }
            else
            {
                await ReplyAsync($"You have not proposed to {user.Username}!");
            }
        }
예제 #8
0
        public async Task AfkUser([Remainder] string message = "")
        {
            // Create a target of type SocketGuild so we can retreive information from the GuildProfiles
            SocketGuild target = null;

            target = Context.Guild;
            var guildProfile = GuildProfiles.GetAccount(target); // Guild Profile

            if (guildProfile.AfkModule)
            {
                var userProfile = UserProfiles.GetAccount(Context.User);

                userProfile.Afk        = true;
                userProfile.AfkMessage = message;
                UserProfiles.SaveProfiles();
                await Context.Channel.SendMessageAsync($"Marking you as away **{Context.User.Username}**");
            }
        }
예제 #9
0
        public async Task Default(IGuildUser user, uint amount)
        {
            var currentUser  = UserProfiles.GetAccount(Context.User);
            var transferUser = UserProfiles.GetAccount((SocketUser)user);

            if (currentUser.Points >= amount)
            {
                currentUser.Points  -= amount;
                transferUser.Points += amount;
                UserProfiles.SaveProfiles();

                await ReplyAsync($":white_check_mark: | {Context.User.Username}, you sent {amount} to **{user.Username}**");
            }
            else
            {
                await ReplyAsync($":negative_squared_cross_mark: | {Context.User.Username}, you do not have enough Nico Nii's.");
            }
        }
예제 #10
0
        public async Task UserProfileInfo([Remainder] string users = null)
        {
            SocketUser target        = null;
            var        mentionedUser = Context.Message.MentionedUsers.FirstOrDefault();

            target = mentionedUser ?? Context.User;

            var marriages = UserProfiles.GetMarriages(target);
            var xp        = UserProfiles.GetXP(target);
            var level     = UserProfiles.GetLevel(target);
            var currency  = UserProfiles.GetCurrency(target);
            var id        = UserProfiles.GetId(target);

            var joinAt = Context.Guild.CurrentUser.JoinedAt;

            var userPf = UserProfiles.GetAccount(target);

            // Set username in profile for updated username
            userPf.Username = target.Username;
            UserProfiles.SaveProfiles();

            var embed = new EmbedBuilder()
                        .WithColor(255, 73, 167)
                        .WithThumbnailUrl(target.GetAvatarUrl())
                        .WithAuthor($"{target.Username}'s Global Profile")
                        .AddField("Level & EXP", level + " [" + level + "/" + xp + "]", true)
                        .AddField("Nico Nii's", $"{currency} <:niconii:451873490883313664>", true)
                        .AddField("ID", id)
                        .AddField("Marriages <:nicolove:451873491130646528>", marriages, true)
                        .WithFooter(footer =>
            {
                footer
                .WithText($"Server Member since {joinAt}");
            });
            await Context.Channel.SendMessageAsync("", embed : embed.Build());
        }
예제 #11
0
        public async Task ConfirmMarriageSlot()
        {
            var userPf        = UserProfiles.GetAccount(Context.User); // You
            var marriageCount = UserProfiles.GetMarriageCount(Context.User);
            var currency      = UserProfiles.GetCurrency(Context.User);

            if (userPf.IsBuyingSlot)
            {
                if (marriageCount == 5)
                {
                    if (currency >= 1000)
                    {
                        UserProfiles.BuyMarriageSlot(Context.User, 1000);
                        await ReplyAsync($"You purchased one slot!");
                    }
                    else
                    {
                        await ReplyAsync($"You do not have enough Nico Nii's to buy a slot.");
                    }
                }
                if (marriageCount == 6)
                {
                    if (currency >= 1500)
                    {
                        UserProfiles.BuyMarriageSlot(Context.User, 1500);
                        await ReplyAsync($"You purchased one slot!");
                    }
                    else
                    {
                        await ReplyAsync($"You do not have enough Nico Nii's to buy a slot.");
                    }
                }
                if (marriageCount == 7)
                {
                    if (currency >= 2000)
                    {
                        UserProfiles.BuyMarriageSlot(Context.User, 2000);
                        await ReplyAsync($"You purchased one slot!");
                    }
                    else
                    {
                        await ReplyAsync($"You do not have enough Nico Nii's to buy a slot.");
                    }
                }
                if (marriageCount == 8)
                {
                    if (currency >= 2500)
                    {
                        UserProfiles.BuyMarriageSlot(Context.User, 2500);
                        await ReplyAsync($"You purchased one slot!");
                    }
                    else
                    {
                        await ReplyAsync($"You do not have enough Nico Nii's to buy a slot.");
                    }
                }
                if (marriageCount == 9)
                {
                    if (currency >= 3000)
                    {
                        UserProfiles.BuyMarriageSlot(Context.User, 3000);
                        await ReplyAsync($"You purchased one slot!");
                    }
                    else
                    {
                        await ReplyAsync($"You do not have enough Nico Nii's to buy a slot.");
                    }
                }
                if (marriageCount == 10)
                {
                    if (currency >= 3500)
                    {
                        UserProfiles.BuyMarriageSlot(Context.User, 3500);
                        await ReplyAsync($"You purchased one slot!");
                    }
                    else
                    {
                        await ReplyAsync($"You do not have enough Nico Nii's to buy a slot.");
                    }
                }
                UserProfiles.SaveProfiles();
            }
        }
예제 #12
0
        // Happens when the bot receives a message
        private async Task HandleCommandAsync(SocketMessage s)
        {
            var msg = s as SocketUserMessage; // Covnert s to a user message

            if (msg == null)
            {
                return;
            }
            var context = new SocketCommandContext(_client, msg);

            if (context.User.IsBot)
            {
                return;
            }

            // Create a target of type SocketGuild so we can retreive information from the GuildProfiles
            SocketGuild target = null;

            target = context.Guild;
            var guildProfile = GuildProfiles.GetAccount(target); // Guild Profile

            int argPos = 0;                                      // Gets rid of the prefix at which position the prefix ends and the msg begins

            if (!File.Exists("Resources/guildProfiles.json"))
            {
                if (msg.HasStringPrefix(Config.bot.cmdPrefix, ref argPos) ||
                    msg.HasMentionPrefix(_client.CurrentUser, ref argPos))
                {
                    var result = await _service.ExecuteAsync(context, argPos); // Executes the commands

                    // Check the result
                    if (!result.IsSuccess && result.Error != CommandError.UnknownCommand)
                    {
                        Console.WriteLine(result.ErrorReason);
                    }
                }
            }
            else
            {
                if (msg.HasStringPrefix(guildProfile.CmdPrefix, ref argPos) ||
                    msg.HasMentionPrefix(_client.CurrentUser, ref argPos))
                {
                    var result = await _service.ExecuteAsync(context, argPos); // Executes the commands

                    // Check the result
                    if (!result.IsSuccess && result.Error != CommandError.UnknownCommand)
                    {
                        Console.WriteLine(result.ErrorReason);
                    }
                }
            }

            if (context.Guild.CurrentUser.GetPermissions(context.Guild.GetChannel(context.Channel.Id)).SendMessages == true)
            {
                //Console.WriteLine(context.Guild.CurrentUser.Username);


                // Mute check
                var userProfile = UserProfiles.GetAccount(context.User);
                if (userProfile.IsMuted)
                {
                    await context.Message.DeleteAsync();

                    return;
                }

                // Leveling up
                Leveling.UserSentMessage((SocketGuildUser)context.User, (SocketTextChannel)context.Channel);

                // RPS Game
                #region RPS
                if (userProfile.IsRPS)
                {
                    Random rnd       = new Random();
                    int    randomInt = rnd.Next(1, 4);
                    string userAns   = msg.Content.ToLower();

                    switch (randomInt)
                    {
                    case 1:
                        // CPU chose rock
                        if (userAns.Contains($"rock"))
                        {
                            await msg.Channel.SendMessageAsync("You chose rock. I chose rock.\nHey! We came to a draw!\n\n**╮( ˘ 、 ˘ )╭**");

                            if (userProfile.IsRPSGamble)
                            {
                                userProfile.Points += userProfile.GambleAmount / 2;
                                await msg.Channel.SendMessageAsync($"You gained {userProfile.GambleAmount / 2} Nico Nii's");
                            }

                            userProfile.IsRPS        = false;
                            userProfile.IsRPSGamble  = false;
                            userProfile.GambleAmount = 0;
                            UserProfiles.SaveProfiles();
                        }
                        else if (userAns.Contains($"paper"))
                        {
                            await msg.Channel.SendMessageAsync("You chose paper. I chose rock.\nAww, you won!\n\n**。゚・ (>﹏<) ・゚。**");

                            if (userProfile.IsRPSGamble)
                            {
                                userProfile.Points += userProfile.GambleAmount * 2;
                                await msg.Channel.SendMessageAsync($"You gained {userProfile.GambleAmount * 2} Nico Nii's");
                            }
                            userProfile.IsRPS        = false;
                            userProfile.IsRPSGamble  = false;
                            userProfile.GambleAmount = 0;
                            UserProfiles.SaveProfiles();
                        }
                        else if (userAns.Contains($"scissors"))
                        {
                            await msg.Channel.SendMessageAsync("You chose scissors. I chose rock.\nYay! I won!\n\n**(๑˃ᴗ˂)ﻭ**");

                            userProfile.IsRPS        = false;
                            userProfile.IsRPSGamble  = false;
                            userProfile.GambleAmount = 0;
                            UserProfiles.SaveProfiles();
                        }
                        break;

                    case 2:
                        // CPU chose paper
                        if (userAns.Contains($"paper"))
                        {
                            await msg.Channel.SendMessageAsync("You chose paper. I chose paper.\nHey! We came to a draw!\n\n**╮( ˘ 、 ˘ )╭**");

                            if (userProfile.IsRPSGamble)
                            {
                                userProfile.Points += userProfile.GambleAmount / 2;
                                await msg.Channel.SendMessageAsync($"You gained {userProfile.GambleAmount / 2} Nico Nii's");
                            }
                            userProfile.IsRPS        = false;
                            userProfile.IsRPSGamble  = false;
                            userProfile.GambleAmount = 0;
                            UserProfiles.SaveProfiles();
                        }
                        else if (userAns.Contains($"rock"))
                        {
                            await msg.Channel.SendMessageAsync("You chose rock. I chose paper.\nYay! I won!\n\n**(๑˃ᴗ˂)ﻭ**");

                            userProfile.IsRPS        = false;
                            userProfile.IsRPSGamble  = false;
                            userProfile.GambleAmount = 0;
                            UserProfiles.SaveProfiles();
                        }
                        else if (userAns.Contains($"scissors"))
                        {
                            await msg.Channel.SendMessageAsync("You chose scissors. I chose paper.\nAww, you won!\n\n**。゚・ (>﹏<) ・゚。**");

                            if (userProfile.IsRPSGamble)
                            {
                                userProfile.Points += userProfile.GambleAmount * 2;
                                await msg.Channel.SendMessageAsync($"You gained {userProfile.GambleAmount * 2} Nico Nii's");
                            }
                            userProfile.IsRPS        = false;
                            userProfile.IsRPSGamble  = false;
                            userProfile.GambleAmount = 0;
                            UserProfiles.SaveProfiles();
                        }
                        break;

                    case 3:
                        // CPU chose scissors
                        if (userAns.Contains($"scissors"))
                        {
                            await msg.Channel.SendMessageAsync("You chose scissors. I chose scissors.\nHey! We came to a draw!\n\n**╮( ˘ 、 ˘ )╭**");

                            if (userProfile.IsRPSGamble)
                            {
                                userProfile.Points += userProfile.GambleAmount / 2;
                                await msg.Channel.SendMessageAsync($"You gained {userProfile.GambleAmount / 2} Nico Nii's");
                            }
                            userProfile.IsRPS        = false;
                            userProfile.IsRPSGamble  = false;
                            userProfile.GambleAmount = 0;
                            UserProfiles.SaveProfiles();
                        }
                        else if (userAns.Contains($"rock"))
                        {
                            await msg.Channel.SendMessageAsync("You chose rock. I chose scissors.\nAww, you won!\n\n**。゚・ (>﹏<) ・゚。**");

                            if (userProfile.IsRPSGamble)
                            {
                                userProfile.Points += userProfile.GambleAmount * 2;
                                await msg.Channel.SendMessageAsync($"You gained {userProfile.GambleAmount * 2} Nico Nii's");
                            }
                            userProfile.IsRPS        = false;
                            userProfile.IsRPSGamble  = false;
                            userProfile.GambleAmount = 0;
                            UserProfiles.SaveProfiles();
                        }
                        else if (userAns.Contains($"paper"))
                        {
                            await msg.Channel.SendMessageAsync("You chose paper. I chose scissors.\nYay! I won!\n\n**(๑˃ᴗ˂)ﻭ**");

                            userProfile.IsRPS        = false;
                            userProfile.IsRPSGamble  = false;
                            userProfile.GambleAmount = 0;
                            UserProfiles.SaveProfiles();
                        }
                        break;

                    default:

                        break;
                    }
                }
                #endregion

                if (context.Guild.CurrentUser.GetPermissions(context.Guild.GetChannel(context.Channel.Id)).EmbedLinks == true)
                {
                    // AFK
                    #region AFK
                    if (guildProfile.AfkModule)
                    {
                        // Set the user back from being AFK if they are AFK
                        if (!s.Author.IsBot && !s.Content.Contains($"{guildProfile.CmdPrefix}afk"))
                        {
                            var afkUser = UserProfiles.GetAccount(s.Author);
                            if (s.Author.Id == afkUser.ID)
                            {
                                if (afkUser.Afk)
                                {
                                    afkUser.Afk        = false;
                                    afkUser.AfkMessage = "";
                                    UserProfiles.SaveProfiles();

                                    var embed = new EmbedBuilder();
                                    embed.Color = new Color(222, 77, 156);
                                    embed.Title = $"You are now set as back **{s.Author.Username}**!";
                                    await s.Channel.SendMessageAsync("", embed : embed.Build());
                                }
                            }
                        }

                        // If the user pings an AFK person, give them a notice
                        var userMentioned = s.MentionedUsers.FirstOrDefault();
                        if (userMentioned != null)
                        {
                            var    afkUser   = UserProfiles.GetAccount(userMentioned); // Get the mentioned user
                            string avatarUrl = userMentioned.GetAvatarUrl();

                            if (afkUser.Afk)
                            {
                                var embed = new EmbedBuilder();
                                embed.Color = new Color(222, 77, 156);
                                embed.Title = $"AFK";
                                embed.WithDescription($"**{userMentioned.Username}** is currently away. They left this message:\n\n **{afkUser.AfkMessage}**");
                                embed.WithThumbnailUrl(avatarUrl);
                                await s.Channel.SendMessageAsync("", embed : embed.Build());
                            }
                        }
                    }
                    #endregion
                }
            }
        }