Exemplo n.º 1
0
        public void ChangeCommandAllowed()
        {
            commands.CreateCommand("Command")
            .Parameter("Command", ParameterType.Required)
            .Parameter("Value", ParameterType.Optional)
            .Do(async(e) =>
            {
                string returnstring = "error";
                if (new ServerRepo(new ServerContext()).IsServerVerified(e.Server.Id))
                {
                    if (e.GetArg("Command").ToLower() == "help" || e.GetArg("Command").ToLower() == "?")
                    {
                        returnstring =
                            "Use this command to change the behavior of your server. You can allow and deny the following features:" +
                            "\n- Regionaccount: Allows the user to type -region to get a region role assigned." +
                            "\n- Regionparameter: Allow the user to type -region <region> to get a region role assinged." +
                            "\n- Rankaccount: Allow the user to type -rank to get a rank role assinged." +
                            "\n- Rankparameter: Allow the user to type -rank <rank> to get a rank role assinged." +
                            "\n- Roleaccount: Allow the user to type -role and get a role assigned that fits their main role in League of Legends." +
                            "\n- Roleparameter: Allow the user to type -role <role> to get that role assigned." +
                            "\n- MasteryAccount: Allow the user to type -mastery and get their amount of points assigned." +
                            "\n\nPlease use the format -Command <Command> <Value>, example: *-Command rankaccount true*.";
                    }
                    else
                    {
                        bool value = false;
                        if (bool.TryParse(e.GetArg("Value"), out value))
                        {
                            if (new ServerRepo(new ServerContext()).IsAdmin(e.User.Id, e.Server.Id))
                            {
                                if (e.GetArg("Command").ToLower() == "rankaccount")
                                {
                                    new SettingsRepo(new SettingsContext()).ToggleAccountRank(value, e.Server.Id);
                                    returnstring = Eng_Default.CommandPermsChanged("Rank by account",
                                                                                   value.ToString());
                                }
                                else if (e.GetArg("Command").ToLower() == "rankparameter")
                                {
                                    new SettingsRepo(new SettingsContext()).ToggleRankParameter(value, e.Server.Id);
                                    returnstring = Eng_Default.CommandPermsChanged("Rank by parameter",
                                                                                   value.ToString());
                                }
                                else if (e.GetArg("Command").ToLower() == "regionaccount")
                                {
                                    new SettingsRepo(new SettingsContext()).ToggleRegionAccount(value, e.Server.Id);
                                    returnstring = Eng_Default.CommandPermsChanged("Region by account",
                                                                                   value.ToString());
                                }
                                else if (e.GetArg("Command").ToLower() == "regionparameter")
                                {
                                    new SettingsRepo(new SettingsContext()).ToggleRegionParameter(value, e.Server.Id);
                                    returnstring = Eng_Default.CommandPermsChanged("Region by parameter",
                                                                                   value.ToString());
                                }
                                else if (e.GetArg("Command").ToLower() == "roleaccount")
                                {
                                    new SettingsRepo(new SettingsContext()).ChangeRoleAccount(value, e.Server.Id);
                                    returnstring = Eng_Default.CommandPermsChanged("Role by account",
                                                                                   value.ToString());
                                }
                                else if (e.GetArg("Command").ToLower() == "roleparameter")
                                {
                                    new SettingsRepo(new SettingsContext()).ChangeRoleParameter(value, e.Server.Id);
                                    returnstring = Eng_Default.CommandPermsChanged("Role by parameter",
                                                                                   value.ToString());
                                }
                                else if (e.GetArg("Command").ToLower() == "masteryaccount")
                                {
                                    new SettingsRepo(new SettingsContext()).ChangeMasteryAccount(value, e.Server.Id);
                                    returnstring =
                                        Eng_Default.CommandPermsChanged("Mastery by account", value.ToString()) +
                                        "\nDon't forget to configure this by using -ConfigMastery!";
                                }
                                else
                                {
                                    returnstring = Eng_Default.PermsCommandNotFound();
                                }
                            }
                            else
                            {
                                returnstring = Eng_Default.NotAllowed();
                            }
                        }
                        else
                        {
                            returnstring = Eng_Default.InvalidBoolValue();
                        }
                    }
                }
                else
                {
                    returnstring = Eng_Default.ServerIsNotVerified();
                }

                await e.Channel.SendMessage(returnstring);
            });
        }