Exemple #1
0
        public async Task WhatLevelIs([Remainder] string arg = "")
        {
            var        user          = Context.User as SocketGuildUser;
            SocketUser target        = null;
            var        mentionedUser = Context.Message.MentionedUsers.FirstOrDefault();

            target = mentionedUser ?? Context.User;
            var account     = GlobalGuildUserAccounts.GetUserID((SocketGuildUser)target);
            var application = await Context.Client.GetApplicationInfoAsync();

            var thumbnailurl = user.GetAvatarUrl();
            var auth         = new EmbedAuthorBuilder()

            {
                Name    = user.Username,
                IconUrl = thumbnailurl,
            };

            uint level = account.LevelNumber;

            var embed = new EmbedBuilder
            {
                Color  = new Color(37, 152, 255),
                Author = auth
            };

            embed.WithTitle("You are level " + level);
            await Context.Channel.SendMessageAsync("", embed : embed.Build());
        }
Exemple #2
0
        public async Task Warnings(IGuildUser user)
        {
            var guildUser = Context.User as SocketGuildUser;

            if (!guildUser.GuildPermissions.ManageMessages)
            {
                string description =
                    $"{Global.ENo} **|** You Need the **Manage Messages** Permission to do that {Context.User.Username}";
                var errorEmbed = EmbedHandler.CreateEmbed(Context, "Error", description,
                                                          EmbedHandler.EmbedMessageType.Exception);
                await ReplyAndDeleteAsync("", embed : errorEmbed);

                return;
            }

            var num      = GlobalGuildUserAccounts.GetUserID((SocketGuildUser)user).NumberOfWarnings;
            var warnings = GlobalGuildUserAccounts.GetUserID((SocketGuildUser)user).Warnings;
            var embed    = new EmbedBuilder();

            embed.WithTitle($"{user}'s Warnings");
            embed.WithDescription($"Total of **{num}** warnings");
            for (var i = 0; i < warnings.Count; i++)
            {
                embed.AddField($"Warning #{i + 1}: ", warnings[i], true);
            }

            await SendMessage(Context, embed.Build());
        }
Exemple #3
0
        public async Task Stats([Remainder] string arg = "")
        {
            SocketUser target        = null;
            var        mentionedUser = Context.Message.MentionedUsers.FirstOrDefault();

            target = mentionedUser ?? Context.User;

            var  userAccount = GlobalGuildUserAccounts.GetUserID((SocketGuildUser)target);
            uint Level       = userAccount.LevelNumber;

            GlobalGuildUserAccounts.SaveAccounts();
            var xp         = userAccount.XP;
            var requiredXp = (Math.Pow(userAccount.LevelNumber + 1, 2) * 50);

            var thumbnailurl = target.GetAvatarUrl();
            var auth         = new EmbedAuthorBuilder()
            {
                Name    = target.Username,
                IconUrl = thumbnailurl,
            };

            var embed = new EmbedBuilder()
            {
                Author = auth
            };

            embed.WithColor(37, 152, 255);
            embed.AddField("Lvl.", Level, true);
            embed.AddField("Exp.", $"{xp}/{requiredXp} (tot. {userAccount.XP})", true);
            embed.AddField("Reputation Points", userAccount.Reputation, true);

            await Context.Channel.SendMessageAsync("", embed : embed.Build());
        }
Exemple #4
0
        public async Task Warnings(IGuildUser user)
        {
            var guser = Context.User as SocketGuildUser;

            if (guser.GuildPermissions.BanMembers)
            {
                var num      = GlobalGuildUserAccounts.GetUserID((SocketGuildUser)user).NumberOfWarnings;
                var warnings = GlobalGuildUserAccounts.GetUserID((SocketGuildUser)user).Warnings;
                var embed    = new EmbedBuilder();
                embed.WithTitle($"{user}'s Warnings");
                embed.WithDescription($"Total of **{num}** warnings");
                for (var i = 0; i < warnings.Count; i++)
                {
                    embed.AddField($"Warning #{i + 1}: ", warnings[i], true);
                }
                await Context.Channel.SendMessageAsync("", embed : embed.Build());
            }
            else
            {
                var embed = new EmbedBuilder();
                embed.WithColor(37, 152, 255);
                embed.Title = $":x:  | You Need the Ban Members Permission to do that {Context.User.Username}";
                await ReplyAndDeleteAsync("", embed : embed.Build(), timeout : TimeSpan.FromSeconds(5));
            }
        }
Exemple #5
0
        public async Task GetRep(SocketGuildUser userB)
        {
            if (Context.User.Id == userB.Id)
            {
                await Context.Channel.SendMessageAsync("You can't use this command on yourself");
            }
            else
            {
                var result = Daily.GetRep((SocketGuildUser)Context.User);

                if (result.Success)
                {
                    var mentionedUser    = Context.Message.MentionedUsers.FirstOrDefault();
                    var mentionedaccount = GlobalGuildUserAccounts.GetUserID(userB);
                    mentionedaccount.Reputation += 1;
                    GlobalGuildUserAccounts.SaveAccounts();
                    var embed = new EmbedBuilder();
                    embed.WithColor(37, 152, 255);
                    embed.WithDescription($":diamond_shape_with_a_dot_inside:   | {Context.User.Mention} gave {userB.Mention} a reputation point!");
                    await Context.Channel.SendMessageAsync("", embed : embed.Build());
                }
                else
                {
                    var timeSpanString = string.Format("{0:%h} hours {0:%m} minutes {0:%s} seconds", result.RefreshTimeSpan);
                    var embed          = new EmbedBuilder();
                    embed.WithColor(37, 152, 255);
                    embed.WithDescription($":diamond_shape_with_a_dot_inside::arrows_counterclockwise:  | **You already gave someone reputation points recently, {Context.User.Mention}.\nCome back in {timeSpanString}.**");
                    await Context.Channel.SendMessageAsync("", embed : embed.Build());
                }
            }
        }
Exemple #6
0
        public async Task Stats([Remainder] string arg = "")
        {
            SocketUser target        = null;
            var        mentionedUser = Context.Message.MentionedUsers.FirstOrDefault();

            target = mentionedUser ?? Context.User;

            var userAccountt = GlobalGuildUserAccounts.GetUserID((SocketGuildUser)target);
            var userAccount  = GlobalUserAccounts.GetUserAccount(target);

            uint Level        = userAccount.LevelNumber;
            var  xp           = userAccount.XP;
            var  requiredXp   = (Math.Pow(userAccount.LevelNumber + 1, 2) * 50);
            var  thumbnailurl = target.GetAvatarUrl();
            var  auth         = new EmbedAuthorBuilder()
            {
                Name    = target.Username,
                IconUrl = thumbnailurl,
            };

            var embed = new EmbedBuilder()
            {
                Author = auth
            };

            embed.WithColor(Global.NayuColor);
            embed.AddField("Affection Lvl.", Level, true);
            embed.AddField("Exp.", $"{xp}/{requiredXp} (tot. {userAccount.XP})", true);
            embed.AddField("Reputation Points", userAccountt.Reputation, true);
            embed.AddField("Taiyaki", userAccount.Taiyaki, true);
            embed.AddField("Taiyaki From Messages", userAccount.TaiyakiFromMessages, true);
            embed.AddField("Taiyaki From Gambling", userAccount.TaiyakiFromGambling, true);
            embed.AddField("Active Chomusuke", userAccount.ActiveChomusuke);
            await SendMessage(Context, embed.Build());
        }
Exemple #7
0
        public async Task Experience([Remainder] string arg = "")
        {
            var        user          = Context.User as SocketGuildUser;
            SocketUser target        = null;
            var        mentionedUser = Context.Message.MentionedUsers.FirstOrDefault();

            //var mentionedUser = Context.Message.MentionedUsers.FirstOrDefault(u => !u.IsBot);
            target = mentionedUser ?? Context.User;

            var account    = GlobalGuildUserAccounts.GetUserID((SocketGuildUser)target);
            var requiredXp = (Math.Pow(account.LevelNumber + 1, 2) * 50);
            var Xp         = account.XP;

            var thumbnailurl = user.GetAvatarUrl();

            var auth = new EmbedAuthorBuilder()
            {
                Name    = user.Username,
                IconUrl = thumbnailurl,
            };

            var embed = new EmbedBuilder()
            {
                Author = auth
            };

            embed.WithColor(37, 152, 255);
            embed.WithTitle($"{target.Username} has {Xp}/{requiredXp} XP");
            await Context.Channel.SendMessageAsync("", embed : embed.Build());
        }
Exemple #8
0
        public async Task GetRep([NoSelf] SocketGuildUser userB)
        {
            var result = Daily.GetRep((SocketGuildUser)Context.User);

            if (result.Success)
            {
                var mentionedAccount = GlobalGuildUserAccounts.GetUserID(userB);
                mentionedAccount.Reputation += 1;
                GlobalGuildUserAccounts.SaveAccounts();
                var embed = new EmbedBuilder();
                embed.WithColor(Global.NayuColor);
                embed.WithDescription(
                    $":diamond_shape_with_a_dot_inside:   **|** {Context.User.Mention} gave {userB.Mention} a reputation point!");
                await SendMessage(Context, embed.Build());
            }
            else
            {
                var timeSpanString =
                    string.Format("{0:%h} hours {0:%m} minutes {0:%s} seconds", result.RefreshTimeSpan);
                var embed = new EmbedBuilder();
                embed.WithColor(Global.NayuColor);
                embed.WithDescription(
                    $":diamond_shape_with_a_dot_inside::arrows_counterclockwise:  | **You already gave someone reputation points recently, {Context.User.Mention}.\nCome back in {timeSpanString}.**");
                await SendMessage(Context, embed.Build());
            }
        }
Exemple #9
0
        public async Task AddXP(uint xp, IGuildUser user, [Remainder] string arg = "")
        {
            SocketUser target        = null;
            var        mentionedUser = Context.Message.MentionedUsers.FirstOrDefault();

            target = mentionedUser ?? Context.User;
            var userAccount = GlobalGuildUserAccounts.GetUserID((SocketGuildUser)user);

            userAccount.XP += xp;
            GlobalGuildUserAccounts.SaveAccounts();
            await Context.Channel.SendMessageAsync($":white_check_mark:  | **{xp}** Exp were added to " + target.Username + "'s account.");
        }
Exemple #10
0
        public async Task AddPoints(uint Points, SocketGuildUser user, [Remainder] string arg = "")
        {
            SocketUser target        = null;
            var        mentionedUser = Context.Message.MentionedUsers.FirstOrDefault();

            target = mentionedUser ?? Context.User;
            var userAccount = GlobalGuildUserAccounts.GetUserID(user);

            userAccount.Reputation += Points;
            GlobalGuildUserAccounts.SaveAccounts();

            var embed = new EmbedBuilder();

            embed.WithColor(37, 152, 255);
            embed.WithTitle($":white_check_mark:  | **{Points}** reputation points were added to " + target.Username + "'s account.");
            await Context.Channel.SendMessageAsync("", embed : embed.Build());
        }
Exemple #11
0
        public async Task WarnUser([NoSelf] IGuildUser user, [Remainder] string reason = "No reason provided.")
        {
            var guildUser = Context.User as SocketGuildUser;

            if (!guildUser.GuildPermissions.ManageMessages)
            {
                string description =
                    $"{Global.ENo} **|** You Need the **Manage Messages** Permission to do that {Context.User.Username}";
                var errorEmbed = EmbedHandler.CreateEmbed(Context, "Error", description,
                                                          EmbedHandler.EmbedMessageType.Exception);
                await ReplyAndDeleteAsync("", embed : errorEmbed);

                return;
            }

            if (user == null)
            {
                var embed = EmbedHandler.CreateEmbed(Context, "Error",
                                                     "🖐️ **|** Please say who you want to warn and a reason for their warning. Ex: n!warn @Phytal bullied my brother",
                                                     EmbedHandler.EmbedMessageType.Exception);
                await ReplyAndDeleteAsync("", embed : embed);
            }

            var userAccount = GlobalGuildUserAccounts.GetUserID((SocketGuildUser)user);
            var dmChannel   = await user.GetOrCreateDMChannelAsync();

            try
            {
                var dmDesc  = $"You have been warned in **{Context.Guild.Name}** for:\n {reason}\nYou now have Warning{(userAccount.NumberOfWarnings == 1 ? "" : "s")}";
                var dmEmbed = EmbedHandler.CreateEmbed(Context, "Warning", dmDesc, EmbedHandler.EmbedMessageType.Info, false);
                await dmChannel.SendMessageAsync("", embed : dmEmbed);
            }
            catch (Exception)
            {
                //nothing should happen and it doesn't matter if anything does happen
            }
            userAccount.NumberOfWarnings++;
            userAccount.Warnings.Add(reason);
            GlobalGuildUserAccounts.SaveAccounts();

            var desc         = $"Successfully warned **{user.Username}** for **{reason}**. **({userAccount.NumberOfWarnings} Warning{(userAccount.NumberOfWarnings == 1 ? "" : "s")})**";
            var successEmbed = EmbedHandler.CreateEmbed(Context, "Warning", desc, EmbedHandler.EmbedMessageType.Success);

            await SendMessage(Context, successEmbed);
        }
Exemple #12
0
        public async Task AddPoints(uint Points, SocketGuildUser user, [Remainder] string arg = "")
        {
            SocketUser target        = null;
            var        mentionedUser = Context.Message.MentionedUsers.FirstOrDefault();

            target = mentionedUser ?? Context.User;
            var userAccount = GlobalGuildUserAccounts.GetUserID(user);

            userAccount.Reputation += Points;
            GlobalGuildUserAccounts.SaveAccounts();


            var embed = EmbedHandler.CreateEmbed(Context, "Success!",
                                                 $"✅  **|** **{Points}** reputation points were added to {target.Username}'s account.",
                                                 EmbedHandler.EmbedMessageType.Success, false);

            await SendMessage(Context, embed);
        }
Exemple #13
0
        public static DailyResult GetRep(SocketGuildUser user)
        {
            var account    = GlobalGuildUserAccounts.GetUserID(user);
            var difference = DateTime.UtcNow - account.LastRep.AddDays(1);

            if (difference.TotalHours < 0)
            {
                return new DailyResult {
                           Success = false, RefreshTimeSpan = difference
                }
            }
            ;

            account.LastRep = DateTime.UtcNow;
            GlobalGuildUserAccounts.SaveAccounts();
            return(new DailyResult {
                Success = true
            });
        }
    }
Exemple #14
0
        internal static async Task Level(SocketGuildUser user, SocketTextChannel channel)
        {
            var config      = GlobalGuildAccounts.GetGuildAccount(user.Guild.Id);
            var userAccount = GlobalGuildUserAccounts.GetUserID(user);
            var dmchannel   = await user.GetOrCreateDMChannelAsync();

            DateTime now = DateTime.UtcNow;

            if (now < userAccount.LastXPMessage.AddSeconds(Constants.MessageXPCooldown))
            {
                return;
            }

            userAccount.LastXPMessage = now;

            uint oldLevel = userAccount.LevelNumber;

            userAccount.XP += 13;
            GlobalGuildUserAccounts.SaveAccounts();
            uint newLevel = userAccount.LevelNumber;

            if (oldLevel != newLevel)
            {
                if (config.LevelingMsgs == "server")
                {
                    await channel.SendMessageAsync($"Level Up! {user.Username}, you just advanced to level {newLevel}!");

                    return;
                }
                if (config.LevelingMsgs == "dm")
                {
                    await dmchannel.SendMessageAsync($"Level Up! {user.Username}, you just advanced to level {newLevel}!");

                    return;
                }
            }
            else
            {
                return;
            }
        }
Exemple #15
0
        public async Task ClearWarnings(IGuildUser user)
        {
            var guser = Context.User as SocketGuildUser;

            if (guser.GuildPermissions.BanMembers)
            {
                var userAccount = GlobalGuildUserAccounts.GetUserID((SocketGuildUser)user);
                userAccount.NumberOfWarnings = 0;
                userAccount.Warnings.Clear();
                GlobalGuildUserAccounts.SaveAccounts();

                await Context.Channel.SendMessageAsync($":white_check_mark:  Succesfully cleared all of **{user.Username}'s** warnings.");
            }
            else
            {
                var embed = new EmbedBuilder();
                embed.WithColor(37, 152, 255);
                embed.Title = $":x:  | You Need the Ban Members Permission to do that {Context.User.Username}";
                await ReplyAndDeleteAsync("", embed : embed.Build(), timeout : TimeSpan.FromSeconds(5));
            }
        }
Exemple #16
0
        public async Task ClearWarnings(IGuildUser user)
        {
            var guildUser = Context.User as SocketGuildUser;

            if (!guildUser.GuildPermissions.ManageMessages)
            {
                string description =
                    $"{Global.ENo} **|** You Need the **Manage Messages** Permission to do that {Context.User.Username}";
                var errorEmbed = EmbedHandler.CreateEmbed(Context, "Error", description,
                                                          EmbedHandler.EmbedMessageType.Exception);
                await ReplyAndDeleteAsync("", embed : errorEmbed);

                return;
            }

            var userAccount = GlobalGuildUserAccounts.GetUserID((SocketGuildUser)user);

            userAccount.NumberOfWarnings = 0;
            userAccount.Warnings.Clear();
            GlobalGuildUserAccounts.SaveAccounts();

            await SendMessage(Context, null, $"✅  Succesfully cleared all of **{user.Username}'s** warnings.");
        }
Exemple #17
0
        public static Task CheckDuelRewards(SocketGuildUser user)
        {
            var userAccount = GlobalGuildUserAccounts.GetUserID(user);
            var config      = GlobalUserAccounts.GetUserAccount(user);
            int wins        = config.Wins;

            if (wins == 10)
            {
                if (config.Attacks.Contains("Bash"))
                {
                    config.Attacks.Add("Bash");
                }
            }
            if (wins == 30)
            {
                if (config.Attacks.Contains("Fireball"))
                {
                    config.Attacks.Add("Fireball");
                }
            }
            if (wins == 50)
            {
                if (config.Attacks.Contains("Meditate"))
                {
                    config.Attacks.Add("Meditate");
                }
            }
            if (wins == 70)
            {
                if (config.Attacks.Contains("Earth Shatter"))
                {
                    config.Attacks.Add("Earth Shatter");
                }
            }
            GlobalUserAccounts.SaveAccounts();
            return(Task.CompletedTask);
        }
Exemple #18
0
        public async Task WarnUser(IGuildUser user, [Remainder] string reason = "No reason provided.")
        {
            var guser = Context.User as SocketGuildUser;

            if (guser.GuildPermissions.BanMembers)
            {
                try
                {
                    var userAccount = GlobalGuildUserAccounts.GetUserID((SocketGuildUser)user);
                    var dmchannel   = await user.GetOrCreateDMChannelAsync();

                    userAccount.NumberOfWarnings++;
                    userAccount.Warnings.Add(reason);
                    GlobalGuildUserAccounts.SaveAccounts();

                    if (userAccount.NumberOfWarnings >= 5)
                    {
                        await user.Guild.AddBanAsync(user);

                        try
                        {
                            await dmchannel.SendMessageAsync($":exclamation:  **You have been banned from** ***{Context.Guild}*** ** from having too many warnings.**");
                        }
                        catch
                        {
                            await Context.Channel.SendMessageAsync($":exclamation:  **{user.Mention} has been banned from** ***{Context.Guild}*** ** from having too many warnings.** \n*This message was shown in a server text channel because you had DMs turned off.*");
                        }
                        await Context.Channel.SendMessageAsync($"Successfully warned and banned**{user.Username}** for **{reason}**. **({userAccount.NumberOfWarnings}/5)**");
                    }
                    else if (userAccount.NumberOfWarnings == 3 || userAccount.NumberOfWarnings == 4)
                    {
                        await user.KickAsync();

                        try
                        {
                            await dmchannel.SendMessageAsync($":exclamation:  **You have been kicked from** ***{Context.Guild}*** **. Think over your actions and you may rejoin the server once you are ready. (5 Warnings = Ban)**");
                        }
                        catch
                        {
                            await Context.Channel.SendMessageAsync($":exclamation:  **{user.Mention} has been kicked from** ***{Context.Guild}*** **. Think over your actions and you may rejoin the server once you are ready. (5 Warnings = Ban)** \n*This message was shown in a server text channel because you had DMs turned off.*");
                        }
                        await Context.Channel.SendMessageAsync($"Successfully warned and kicked **{user.Username}** for **{reason}**. **({userAccount.NumberOfWarnings}/5)**");
                    }
                    else if (userAccount.NumberOfWarnings == 1 || userAccount.NumberOfWarnings == 2)
                    {
                        try
                        {
                            await dmchannel.SendMessageAsync($":exclamation:  **You have been warned in** ***{Context.Guild}*** **. (5 Warnings = Ban)**");
                        }
                        catch
                        {
                            await Context.Channel.SendMessageAsync($":exclamation:  **{user.Mention} has been warned in** ***{Context.Guild}*** **. (5 Warnings = Ban)**\n*This message was shown in a server text channel because you had DMs turned off.*");
                        }
                        await Context.Channel.SendMessageAsync($"Successfully warned **{user.Username}** for **{reason}**. **({userAccount.NumberOfWarnings}/5)**");
                    }
                }
                catch
                {
                    if (user == null)
                    {
                        var embed = new EmbedBuilder();
                        embed.WithColor(37, 152, 255);
                        embed.WithTitle(":hand_splayed:  | Please say who you want to warn and a reason for their warning. Ex: w!warn @Phytal bullied my brother");
                        await ReplyAndDeleteAsync("", embed : embed.Build(), timeout : TimeSpan.FromSeconds(5));
                    }
                }
            }
            else
            {
                var embed = new EmbedBuilder();
                embed.WithColor(37, 152, 255);
                embed.Title = $":x:  | You Need the Ban Members Permission to do that {Context.User.Username}";
                await ReplyAndDeleteAsync("", embed : embed.Build(), timeout : TimeSpan.FromSeconds(5));
            }
        }