Esempio n. 1
0
        SetNotificationChannelAsync(SocketTextChannel _channel)
        {
            //On server has text channel.
            if (Context.Guild.Channels.Contains(_channel))
            {
                //Execute query.
                CoreModule.ExecuteQuery(Context.Guild.Id,
                                        $"update settings set notificationChannel =" +
                                        $" '{_channel.Name}';");

                //Create and set embed object.
                var embed = CoreModule.SimpleEmbed(Color.Green,
                                                   "Set notification's channel completed",
                                                   $"The **channel** {_channel.Mention}" +
                                                   $" has been **set**.");

                //Reply embed.
                await ReplyAsync("", false, embed.Build());

                //Send notification
                CoreModule.SendNotification(Context.Guild.Id,
                                            "Notification's channel changed",
                                            $"{Context.User.Mention} **changed** the Notification's" +
                                            $" channel to {_channel.Mention}.");
            }
        }
Esempio n. 2
0
        SetNotificationsAsync(bool _boolean)
        {
            //On true.
            if (_boolean)
            {
                //Execute query.
                CoreModule.ExecuteQuery(Context.Guild.Id,
                                        $"UPDATE settings SET notifications = 'On';");

                //Create and set embed object.
                var embed = CoreModule.SimpleEmbed(Color.Green,
                                                   "Set notifications completed",
                                                   $"The **notifications** have been set **`On`**.");

                //Reply embed.
                await ReplyAsync("", false, embed.Build());

                //Send notification
                CoreModule.SendNotification(Context.Guild.Id,
                                            "Notification settings changed",
                                            $"{Context.User.Mention} **changed** the Notification" +
                                            $" settings to **`On`**.");
            }
            //On false.
            else
            {
                //Send notification.
                CoreModule.SendNotification(Context.Guild.Id,
                                            "Notification settings changed",
                                            $"{Context.User.Mention} **changed** the Notification" +
                                            $" settings to **`Off`**.");

                //Execute query.
                CoreModule.ExecuteQuery(Context.Guild.Id,
                                        $"UPDATE settings SET notifications = 'Off';");

                //Create and set embed content.
                var embed = CoreModule.SimpleEmbed(Color.Green,
                                                   "Set notifications completed",
                                                   $"The **notifications** have been set **`Off`**.");

                //Reply embed.
                await ReplyAsync("", false, embed.Build());
            }
        }
Esempio n. 3
0
        StartNewStatsAsync()
        {
            //Execute query.
            CoreModule.ExecuteQuery(Context.Guild.Id, "UPDATE users SET lastXP = actualXP;");

            //Create and set embed object.
            var embed = CoreModule.SimpleEmbed(Color.Green,
                                               "Start new stats completed",
                                               "The **`new stats`** of the database is completed.");

            //Send notification.
            CoreModule.SendNotification(Context.Guild.Id,
                                        "Started new server stats",
                                        $"{Context.User.Mention} **started** new database stats.");

            //Reply embed.
            await ReplyAsync("", false, embed.Build());
        }
Esempio n. 4
0
        SetPrefixAsync(string _prefix)
        {
            //Execute query.
            CoreModule.ExecuteQuery(Context.Guild.Id, $"update settings set prefix = '{_prefix}';");

            //Set embed content.
            var embed = CoreModule.SimpleEmbed(Color.Green,
                                               "Set prefix completed",
                                               $"The **prefix** **`{_prefix}`** has been **set**.");

            //Reply embed.
            await ReplyAsync("", false, embed.Build());

            //Send notification.
            CoreModule.SendNotification(Context.Guild.Id,
                                        "prefix changed",
                                        $"{Context.User.Mention} **changed** the prefix to" +
                                        $" **`{_prefix}`**.");
        }
Esempio n. 5
0
        RenameUsernameAsync(string _username, [Remainder] SocketGuildUser _user)
        {
            //On user on database.
            if (CoreModule.UserExistsServerDB(Context.Guild.Id, _user.Id))
            {
                //Execute query.
                CoreModule.ExecuteQuery(Context.Guild.Id,
                                        $"UPDATE users SET name = '{_username}'" +
                                        $" where id = {_user.Id};");

                //Set embed object
                var embed = CoreModule.SimpleEmbed(Color.Green,
                                                   "Update completed",
                                                   $"The **update** of the user {_user.Mention}" +
                                                   $" is **completed**.");

                //Reply embed.
                await ReplyAsync("", false, embed.Build());

                //Send notification.
                CoreModule.SendNotification(Context.Guild.Id,
                                            "User username updated",
                                            $"{Context.User.Mention} **updated** the user" +
                                            $" {_user.Mention} database username to" +
                                            $" **`{_username}`**.");
            }
            //On user not on database.
            else
            {
                //Create and set embed content.
                var embed = CoreModule.SimpleEmbed(Color.Red,
                                                   "User not found",
                                                   $"{_user.Mention} doesn't exist on the database," +
                                                   $" **`update aborted`**.");

                //Reply embed.
                await ReplyAsync("", false, embed.Build());
            }
        }
Esempio n. 6
0
        DeleteAsync([Remainder] SocketGuildUser _user)
        {
            //On user on database.
            if (CoreModule.UserExistsServerDB(Context.Guild.Id, _user.Id))
            {
                //Execute query.
                CoreModule.ExecuteQuery(Context.Guild.Id,
                                        $"DELETE FROM users WHERE id = {_user.Id};");

                //Create and set embed object.
                var embed = CoreModule.SimpleEmbed(Color.Green,
                                                   "Delete completed",
                                                   $"The **delete** of the user" +
                                                   $" {_user.Mention} is **completed**.");

                //Reply embed.
                await ReplyAsync("", false, embed.Build());

                //Send notification.
                CoreModule.SendNotification(Context.Guild.Id,
                                            "User deleted",
                                            $"{Context.User.Mention} **deleted** the user" +
                                            $" {_user.Mention} from the database.");
            }
            //On user not on database.
            else
            {
                //Create and set embed object.
                var embed = CoreModule.SimpleEmbed(Color.Red,
                                                   "User not found",
                                                   $"{_user.Mention} doesn't exist on the database," +
                                                   $" **`delete aborted`**.");

                //Reply embed.
                await ReplyAsync("", false, embed.Build());
            }
        }
Esempio n. 7
0
        SetRoleAsync(SocketRole _role)
        {
            //On server has role.
            if (Context.Guild.Roles.Contains(_role))
            {
                //Execute query.
                CoreModule.ExecuteQuery(Context.Guild.Id,
                                        $"update settings set role = '{_role.Name}';");

                //Create and set embed object.
                var embed = CoreModule.SimpleEmbed(Color.Green,
                                                   "Set role completed",
                                                   $"The **role** {_role.Mention} has been **set**.");

                //Reply embed
                await ReplyAsync("", false, embed.Build());

                //Send notification.
                CoreModule.SendNotification(Context.Guild.Id,
                                            "Member role changed",
                                            $"{Context.User.Mention} **changed** the Guild Member" +
                                            $" **role** to {_role.Mention}.");
            }
        }
Esempio n. 8
0
        SignupAsync(string _username, string _region)
        {
            //Create and set socket guild user.
            SocketGuildUser user = Context.User as SocketGuildUser;

            //Create and set role.
            SocketRole role = CoreModule.GetRole(Context.Guild.Id, Context);

            //On socket guild user contains guild member role.
            if (user.Roles.Contains(role))
            {
                //On user not on database.
                if (!CoreModule.UserExistsServerDB(Context.Guild.Id, user.Id))
                {
                    //Execute query.
                    CoreModule.ExecuteQuery(Context.Guild.Id,
                                            "INSERT INTO users (id,name,region,actualXP,lastXP)" +
                                            $" VALUES ({user.Id},'{_username}','{_region}',0,0);");

                    //Create and set embed object.
                    var embed = CoreModule.SimpleEmbed(Color.Green,
                                                       "Sign up completed",
                                                       $"Your **sign up** is **completed**.");

                    //Reply embed.
                    await ReplyAsync("", false, embed.Build());

                    //Send notification
                    CoreModule.SendNotification(Context.Guild.Id,
                                                "User registered",
                                                $"{user.Mention} **registered** to the database.");
                }
                //On user in database.
                else
                {
                    //Create and set embed object.
                    var embed = CoreModule.SimpleEmbed(Color.Red,
                                                       "User found",
                                                       "You're already on the database," +
                                                       " **`sign up aborted`**.");

                    //Reply embed.
                    await ReplyAsync("", false, embed.Build());
                }
            }
            //On socket guild user not contains role.
            else
            {
                //Create embed object.
                EmbedBuilder embed;

                //On role exist.
                if (role != null)
                {
                    //Set embed object.
                    embed = CoreModule.SimpleEmbed(Color.Red,
                                                   "Not a member",
                                                   $"{user.Mention} you're not allowed to use this" +
                                                   $" command, only {role.Mention} is allowed" +
                                                   $" to use it.");
                }
                //Otherwise role don't exist.
                else
                {
                    //Set embed object.
                    embed = CoreModule.SimpleEmbed(Color.Red,
                                                   "Role not set",
                                                   "The **role** to use the commands has" +
                                                   " **not been set**, please use `~setrole` to set" +
                                                   " the role, **`sign up aborted`**.");
                }

                //Reply embed.
                await ReplyAsync("", false, embed.Build());
            }
        }