public async Task TopAsync()
        {
            //Aqui você substitui pelos seus dados
            var connString = "Server=192.168.1.141;Port=3306;Database=lebot;Uid=lebot;Pwd=;SslMode=none;";
            var connection = new MySqlConnection(connString);
            var command    = connection.CreateCommand();

            try
            {
                connection.Open();
                command.CommandText = "SELECT userid, coins FROM currency ORDER BY coins DESC LIMIT 5";
                MySqlDataReader coinsReader;
                coinsReader = command.ExecuteReader();

                List <string[]> users = new List <string[]>();

                while (coinsReader.Read())
                {
                    string userID    = coinsReader["userid"].ToString();
                    string userCoins = coinsReader["coins"].ToString();

                    string[] thisUser = { userID, userCoins };

                    users.Add(thisUser);
                }
                EmbedBuilder topUsers = new EmbedBuilder();
                var          getColor = new Functions.RandomBuilderColor();

                topUsers.WithTitle("Quem está mais ligado a Deus?")
                .WithColor(getColor.MessageBuilderColor());

                foreach (var user in users)
                {
                    string nick = "" + Context.Client.GetUser(ulong.Parse("" + user.GetValue(0)));
                    topUsers.AddField("" + nick, "Tem " + user.GetValue(1) + " de fé");
                }

                await ReplyAsync("", false, topUsers);

                coinsReader.Close();
                connection.Close();
            }
            catch (MySqlException ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                if (connection.State == System.Data.ConnectionState.Open)
                {
                    connection.Close();
                }
            }
        }
        public async Task CreditsAsync()
        {
            var          getColor       = new Functions.RandomBuilderColor();
            EmbedBuilder creditsBuilder = new EmbedBuilder();

            creditsBuilder.WithTitle("Creditos d'**O Padre**")
            .WithColor(getColor.MessageBuilderColor())
            .AddField("Ideias por:", "@João Rodrigo Gonçalves#9391 \n@Hikaru#0448")
            .AddField("Programação por:", "@João Rodrigo Gonçalves#9391")
            .AddField("Atenção!", "BOT feito em C# e PHP com :heart: para uso privado!");
            await ReplyAsync("", false, creditsBuilder.Build());
        }
Example #3
0
        public async Task shopHelp()
        {
            var          getColor     = new Functions.RandomBuilderColor();
            EmbedBuilder helpCommands = new EmbedBuilder();

            helpCommands.WithTitle("Comandos da shop d'**padre**!")
            .WithDescription("Comandos da *shop*")
            .WithColor(getColor.MessageBuilderColor())
            .AddInlineField("\\shop `{ordem [id/price/name]}` `{sentido [ASC/DESC]}`", "Mostra toda a shop")
            .AddInlineField("\\buy `{id}`", "Comprar o item selecionado em `id`");

            await ReplyAsync("", false, helpCommands);
        }
Example #4
0
        public async Task defaultHelp()
        {
            var          getColor     = new Functions.RandomBuilderColor();
            EmbedBuilder helpCommands = new EmbedBuilder();

            helpCommands.WithTitle("Comandos d'**O Padre**!")
            .WithDescription("Todos os comandos d'**O Padre**!")
            .WithColor(getColor.MessageBuilderColor())
            .AddInlineField("\\help", "Este menu de ajuda :expressionless:")
            .AddInlineField("\\help shop", "Menu de ajuda da \\shop")
            .AddInlineField("\\credits", "Autores d'**O Padre**")
            .AddInlineField("\\dab", "Precisas de um update :neutral_face:")
            .AddInlineField("\\shutup", "**O Padre** vai fingir que não te está a ouvir...")
            .AddInlineField("\\fe", "Mostra a tua \"fé\"!")
            .AddInlineField("\\lapada `{gajo}`", "Espeta um lapada nesse gajo")
            .AddInlineField("\\give `{quantia}` `{gajo}`", "Dar \"fé\" a um gajo :clap: :pray:")
            .AddInlineField("\\festa", "Não é uma festa sem foguetes! :fireworks:")
            .AddInlineField("\\missa", "Vai á missa e pode ser que o padre te dê muita fé :pray:")
            .AddInlineField("\\top", "Os mais ligados a Deus de sempre! :raised_hands:")
            .AddInlineField("\\bet {quantidade}", "Duplica, triplica ou perde toda a fé que apostares!");

            await ReplyAsync("", false, helpCommands.Build());
        }
Example #5
0
        public async Task MissaAsync()
        {
            var   connString         = "Server=192.168.1.141;Port=3306;Database=lebot;Uid=lebot;Pwd=;SslMode=none;";
            var   connection         = new MySqlConnection(connString);
            var   command            = connection.CreateCommand();
            ulong userReceivingCoins = 10;

            try
            {
                connection.Open();
                command.CommandText = "SELECT coins FROM currency WHERE userid='" + Context.Message.Author.Id + "' LIMIT 1";
                MySqlDataReader coinsReader;
                coinsReader = command.ExecuteReader();
                if (coinsReader.Read())
                {
                    userReceivingCoins = coinsReader.GetUInt32("coins");
                    coinsReader.Close();
                }
                else
                {
                    coinsReader.Close();
                    command.CommandText = "INSERT INTO currency (userid) VALUES ('" + Context.Message.Author.Id + "')";
                    command.ExecuteNonQuery();
                    userReceivingCoins = 10;
                }
                connection.Close();
            }
            catch (MySqlException ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                if (connection.State == System.Data.ConnectionState.Open)
                {
                    connection.Close();
                }
            }
            int  lastday   = 0;
            int  lastmonth = 0;
            int  lastyear  = 0;
            bool exist     = false;

            try
            {
                connection.Open();
                command.CommandText = "SELECT lastday, lastmonth, lastyear FROM missas WHERE userid='" + Context.Message.Author.Id + "' LIMIT 1";
                MySqlDataReader dateReader;
                dateReader = command.ExecuteReader();
                if (dateReader.Read())
                {
                    lastday   = dateReader.GetInt32("lastday");
                    lastmonth = dateReader.GetInt32("lastmonth");
                    lastyear  = dateReader.GetInt32("lastyear");
                    dateReader.Close();
                    exist = true;
                }
                else
                {
                    dateReader.Close();
                    command.CommandText = "INSERT INTO missas (userid, lastday, lastmonth, lastyear) VALUES ('" + Context.Message.Author.Id + "', '" + DateTime.Now.Day + "', '" + DateTime.Now.Month + "', '" + DateTime.Now.Year + "')";
                    command.ExecuteNonQuery();
                    exist = false;
                }
                connection.Close();

                //Check if bool "exist" was changed and if the user exists in the database
                bool allowed = false;
                if (exist)
                {
                    var checkTime = new Functions.TimeCalculation();
                    if (checkTime.TimeClaculations(lastday, lastmonth, lastyear))
                    {
                        allowed = true;
                    }
                }
                else
                {
                    allowed = true;
                }

                if (allowed)
                {
                    Random random       = new Random();
                    int    randomNumber = random.Next(0, 26); //[0, 26[
                    if (randomNumber <= 0)
                    {
                        randomNumber = 1;
                    }
                    ulong userCoins = userReceivingCoins + Convert.ToUInt64(Convert.ToInt64(randomNumber));

                    try
                    {
                        connection.Open();
                        command.CommandText = "UPDATE currency SET coins='" + userCoins + "' WHERE userid='" + Context.Message.Author.Id + "' LIMIT 1";
                        command.ExecuteNonQuery();
                        connection.Close();

                        connection.Open();
                        command.CommandText = "UPDATE missas SET lastday='" + DateTime.Now.Day + "', lastmonth='" + DateTime.Now.Month + "', lastyear='" + DateTime.Now.Year + "' WHERE userid='" + Context.Message.Author.Id + "' LIMIT 1";
                        command.ExecuteNonQuery();
                        connection.Close();

                        EmbedBuilder ammountMessage = new EmbedBuilder();

                        var getColor = new Functions.RandomBuilderColor();
                        ammountMessage.WithTitle("Ganhas-te " + randomNumber + " de fé! :pray:")
                        .WithColor(getColor.MessageBuilderColor());

                        await ReplyAsync("", false, ammountMessage);
                    }
                    catch (MySqlException ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                    finally
                    {
                        if (connection.State == System.Data.ConnectionState.Open)
                        {
                            connection.Close();
                        }
                    }
                }
                else
                {
                    EmbedBuilder warningMessage = new EmbedBuilder();
                    warningMessage.WithTitle("Exedeste o teu limite diário!!")
                    .WithDescription("Tenta novamente amanhã para receberes a tua fé diária!");
                    await ReplyAsync("", false, warningMessage);
                }
            }
            catch (MySqlException ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                if (connection.State == System.Data.ConnectionState.Open)
                {
                    connection.Close();
                }
            }
        }
        public async Task InventoryAsync()
        {
            ulong userid = Context.Message.Author.Id;
            //Aqui você substitui pelos seus dados
            var             connString = "Server=192.168.1.141;Port=3306;Database=lebot;Uid=lebot;Pwd=;SslMode=none;";
            var             connection = new MySqlConnection(connString);
            var             command    = connection.CreateCommand();
            List <string[]> items      = new List <string[]>();
            List <string[]> userItems  = new List <string[]>();

            connection.Open();
            command.CommandText = "SELECT * FROM store_prices";
            MySqlDataReader itemReader;

            itemReader = command.ExecuteReader();
            try
            {
                while (itemReader.Read())
                {
                    string itemId          = itemReader["id"].ToString();
                    string itemName        = itemReader["name"].ToString();
                    string itemPrice       = itemReader["price"].ToString();
                    string itemDescription = itemReader["description"].ToString();

                    string[] thisItem = { itemId, itemName, itemPrice, itemDescription };

                    items.Add(thisItem);
                }
                itemReader.Close();
                connection.Close();

                var ownItem = new Functions.OwnItem();

                foreach (var item in items)
                {
                    if (ownItem.OwnedItem(userid, int.Parse("" + item.GetValue(0))))
                    {
                        string[] thisUserItem = { "" + item.GetValue(0), "" + item.GetValue(1), "" + item.GetValue(2), "" + item.GetValue(3) };
                        userItems.Add(thisUserItem);
                    }
                }

                EmbedBuilder inventoryDump = new EmbedBuilder();
                var          getColor      = new Functions.RandomBuilderColor();

                inventoryDump.WithTitle("Inventário de " + Context.Message.Author.Username + "#" + Context.Message.Author.Discriminator);
                inventoryDump.WithColor(getColor.MessageBuilderColor());

                if (userItems.Count > 0)
                {
                    foreach (var ownedItem in userItems)
                    {
                        inventoryDump.AddField("Id: " + ownedItem.GetValue(0) + " :arrow_right: " + ownedItem.GetValue(1), ownedItem.GetValue(3));
                    }
                }
                else
                {
                    inventoryDump.WithDescription("Nada... Talvez usar a \\shop para encontrar algo?");
                }
                await ReplyAsync("", false, inventoryDump);
            }
            catch (MySqlException ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                if (connection.State == System.Data.ConnectionState.Open)
                {
                    connection.Close();
                }
            }
        }
        public async Task FeAsync([Remainder] string user = null)
        {
            string userid = null;
            string String = null;
            bool   self   = true;

            if (user == null)
            {
                userid = "" + Context.Message.Author.Id;
                String = Context.Message.Author + ", tu tens";
                self   = true;
            }
            else
            {
                var charToRemove = new string[] { "<", "@", "!", ">" };
                foreach (var c in charToRemove)
                {
                    user = user.Replace(c, string.Empty);
                }
                userid = user;
                String = Context.Client.GetUser(ulong.Parse(user)) + " tem";
                self   = false;
            }
            //Aqui você substitui pelos seus dados
            var connString = "Server=192.168.1.141;Port=3306;Database=lebot;Uid=lebot;Pwd=;SslMode=none;";
            var connection = new MySqlConnection(connString);
            var command    = connection.CreateCommand();
            var getColors  = new Functions.RandomBuilderColor();

            try
            {
                connection.Open();
                command.CommandText = "SELECT coins FROM currency WHERE userid='" + userid + "' LIMIT 1";
                MySqlDataReader coinsReader;
                coinsReader = command.ExecuteReader();
                EmbedBuilder coinsAmount = new EmbedBuilder();
                if (coinsReader.Read())
                {
                    uint userCoins = coinsReader.GetUInt32("coins");
                    coinsAmount.WithTitle(String + " " + coinsReader.GetInt32("coins") + " de fé!")
                    .WithColor(getColors.MessageBuilderColor());
                    if (self)
                    {
                        coinsAmount.WithThumbnailUrl("https://cdn.discordapp.com/avatars/" + Context.Message.Author.Id + "/" + Context.Message.Author.AvatarId + ".png?size=128");
                    }
                    else
                    {
                        coinsAmount.WithThumbnailUrl("https://cdn.discordapp.com/avatars/" + Context.Client.GetUser(ulong.Parse(userid)).Id + "/" + Context.Client.GetUser(ulong.Parse(userid)).AvatarId + ".png?size=128");
                    }
                    coinsReader.Close();
                }
                else
                {
                    coinsReader.Close();
                    command.CommandText = "INSERT INTO currency (userid) VALUES ('" + Context.Message.Author.Id + "') LIMIT 1";
                    command.ExecuteNonQuery();

                    coinsAmount.WithTitle(String + " 10 de fé!")
                    .WithColor(getColors.MessageBuilderColor());
                    if (self)
                    {
                        coinsAmount.WithThumbnailUrl("https://cdn.discordapp.com/avatars/" + Context.Message.Author.Id + "/" + Context.Message.Author.AvatarId + ".png?size=128");
                    }
                    else
                    {
                        coinsAmount.WithThumbnailUrl("https://cdn.discordapp.com/avatars/" + Context.Client.GetUser(ulong.Parse(userid)).Id + "/" + Context.Client.GetUser(ulong.Parse(userid)).AvatarId + ".png?size=128");
                    }
                }
                coinsAmount.WithDescription("Consegue mais fé com comandos como \"\\missa\"!");
                await ReplyAsync("", false, coinsAmount);

                connection.Close();
            }
            catch (MySqlException ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                if (connection.State == System.Data.ConnectionState.Open)
                {
                    connection.Close();
                }
            }
        }
Example #8
0
        public async Task ShopAsync(string order = "id", string mode = "ASC")
        {
            if (!order.Equals("id", StringComparison.OrdinalIgnoreCase))
            {
                if (!order.Equals("name", StringComparison.OrdinalIgnoreCase))
                {
                    if (!order.Equals("price", StringComparison.OrdinalIgnoreCase))
                    {
                        await ReplyAsync(Context.Message.Author.Mention + "! Os únicos argumentos válidos para a ordenação dos itens da shop são `id`, `price` e `name`!");

                        return;
                    }
                }
            }

            if (!mode.Equals("ASC", StringComparison.OrdinalIgnoreCase))
            {
                if (!mode.Equals("DESC", StringComparison.OrdinalIgnoreCase))
                {
                    await ReplyAsync(Context.Message.Author.Mention + "! Os únicos argumentos válidos para o sentido da ordenação dos itens da shop são `ASC` e `DESC`!");

                    return;
                }
            }

            //Aqui você substitui pelos seus dados
            var connString = "Server=192.168.1.141;Port=3306;Database=lebot;Uid=lebot;Pwd=;SslMode=none;";
            var connection = new MySqlConnection(connString);
            var command    = connection.CreateCommand();

            try
            {
                connection.Open();
                command.CommandText = "SELECT * FROM store_prices ORDER BY " + order + " " + mode + "";
                MySqlDataReader coinsReader;
                coinsReader = command.ExecuteReader();

                List <string[]> items = new List <string[]>();

                while (coinsReader.Read())
                {
                    string itemId          = coinsReader["id"].ToString();
                    string itemName        = coinsReader["name"].ToString();
                    string itemPrice       = coinsReader["price"].ToString();
                    string itemDescription = coinsReader["description"].ToString();


                    string[] thisItem = { itemId, itemName, itemPrice, itemDescription };

                    items.Add(thisItem);
                }
                EmbedBuilder shopList = new EmbedBuilder();
                var          getColor = new Functions.RandomBuilderColor();

                shopList.WithTitle("Loja d' *O Padre*")
                .WithColor(getColor.MessageBuilderColor());

                foreach (var item in items)
                {
                    shopList.AddField("Id: " + item.GetValue(0) + " :arrow_right: " + item.GetValue(1), item.GetValue(3) + "\n" + "Preço: " + item.GetValue(2) + " de fé :pray:");
                }

                await ReplyAsync("", false, shopList);

                coinsReader.Close();
                connection.Close();
            }
            catch (MySqlException ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                if (connection.State == System.Data.ConnectionState.Open)
                {
                    connection.Close();
                }
            }

            return;
        }
Example #9
0
        public async Task BetAsync([Remainder] string amount = null)
        {
            if (amount != null)
            {
                if (int.TryParse(amount, out int amountConverted))
                {
                    //Aqui você substitui pelos seus dados
                    var connString = "Server=192.168.1.141;Port=3306;Database=lebot;Uid=lebot;Pwd=;SslMode=none;";
                    var connection = new MySqlConnection(connString);
                    var command    = connection.CreateCommand();
                    var getColors  = new Functions.RandomBuilderColor();

                    int currentCoins = 0;

                    try
                    {
                        connection.Open();
                        command.CommandText = "SELECT coins FROM currency WHERE userid='" + Context.Message.Author.Id + "' LIMIT 1";
                        MySqlDataReader coinsReader;
                        coinsReader = command.ExecuteReader();
                        if (coinsReader.Read())
                        {
                            currentCoins = coinsReader.GetInt32("coins");
                            coinsReader.Close();
                        }
                        else
                        {
                            coinsReader.Close();
                            command.CommandText = "INSERT INTO currency (userid) VALUES ('" + Context.Message.Author.Id + "') LIMIT 1";
                            command.ExecuteNonQuery();
                            currentCoins = 10;
                        }
                        connection.Close();
                    }
                    catch (MySqlException ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                    finally
                    {
                        if (connection.State == System.Data.ConnectionState.Open)
                        {
                            connection.Close();
                        }
                    }

                    Random chance       = new Random();
                    int    chanceResult = chance.Next(0, 101);

                    /*
                     *
                     * 0 - 50 -» Lost
                     * 51 - 90 -» Won x2
                     * 91 - 100 -» Won x3
                     *
                     */

                    int newTotal = 0;

                    if (chanceResult <= 50)
                    {
                        try
                        {
                            connection.Open();
                            command.CommandText = "UPDATE currency SET coins='" + (currentCoins - amountConverted) + "' WHERE userid='" + Context.Message.Author.Id + "' LIMIT 1";
                            command.ExecuteNonQuery();
                        }
                        catch (MySqlException ex)
                        {
                            Console.WriteLine(ex.Message);
                        }
                        finally
                        {
                            if (connection.State == System.Data.ConnectionState.Open)
                            {
                                connection.Close();
                            }
                        }
                        await ReplyAsync(Context.Message.Author.Mention + " perdeste " + amountConverted + "...");
                    }
                    else
                    {
                        if (chanceResult >= 51 && chanceResult <= 90)
                        {
                            newTotal = amountConverted * 2;
                        }

                        if (chanceResult >= 91)
                        {
                            newTotal = amountConverted * 3;
                        }

                        int total = newTotal + currentCoins;

                        try
                        {
                            connection.Open();
                            command.CommandText = "UPDATE currency SET coins='" + total + "' WHERE userid='" + Context.Message.Author.Id + "' LIMIT 1";
                            command.ExecuteNonQuery();
                            await ReplyAsync(Context.Message.Author.Mention + ", ganhaste " + newTotal + "!");
                        }
                        catch (MySqlException ex)
                        {
                            Console.WriteLine(ex.Message);
                        }
                        finally
                        {
                            if (connection.State == System.Data.ConnectionState.Open)
                            {
                                connection.Close();
                            }
                        }
                    }
                }
                else
                {
                    await ReplyAsync("Números pah. Tu apostas números crl! Dasse " + Context.Message.Author.Mention + "...");
                }
            }
            else
            {
                await ReplyAsync("Ó " + Context.Message.Author.Mention + "! E dizeres quanto é que vais apostar?");
            }
        }