Ejemplo n.º 1
0
 public async Task ModifyModuleAsync(
     [Summary("The action to perform on the module.")] ModuleActionType action,
     [Summary("The name of the module."), Remainder] string name)
 {
     if (Modules.VerifyModuleName(ref name))
     {
         bool moduleActive = Modules.GetModuleState(name);
         if (action == ModuleActionType.Status)
         {
             await ReplyAsync($"The module **{name}** is currently **{(moduleActive ? "enabled" : "disabled")}**.");
         }
         else
         {
             if ((action == ModuleActionType.Enable && moduleActive) ||
                 (action == ModuleActionType.Disable && !moduleActive))
             {
                 await ReplyAsync($"The module **{name}** is already **{(moduleActive ? "enabled" : "disabled")}**!");
             }
             else
             {
                 bool active = action == ModuleActionType.Enable;
                 await Modules.SetModuleState(name, active);
                 await ReplyAsync($"The module **{name}** is now **{(active ? "enabled" : "disabled")}**!");
             }
         }
     }
     else
     {
         await ReplyAsync($"I don't know a module called **{name}**.");
     }
 }
Ejemplo n.º 2
0
        public async Task ModifyModule(ModuleActionType ModuleActionType, string ModuleName)
        {
            if (Services.ModuleService.VerifyModuleName(ref ModuleName))
            {
                bool IsActive = ModuleService.GetModuleState(ModuleName);

                switch (ModuleActionType)
                {
                case ModuleActionType.Status:
                    await BuildEmbed(IsActive?EmojiEnum.Love : EmojiEnum.Annoyed)
                    .WithTitle("Module ProposalStatus.")
                    .WithDescription($"The module **{ModuleName}** is currently **{(IsActive ? "enabled" : "disabled")}.**")
                    .SendEmbed(Context.Channel);

                    break;

                default:
                    if ((ModuleActionType == ModuleActionType.Enable && IsActive) || (ModuleActionType == ModuleActionType.Disable && !IsActive))
                    {
                        await BuildEmbed(EmojiEnum.Annoyed)
                        .WithTitle("Module already set to value!")
                        .WithDescription($"The module **{ModuleName}** is already **{(IsActive ? "enabled" : "disabled")}.**")
                        .SendEmbed(Context.Channel);
                    }
                    else
                    {
                        bool Active = ModuleActionType == ModuleActionType.Enable;
                        await ModuleService.SetModuleState(ModuleName, Active);
                        await BuildEmbed(Active?EmojiEnum.Love : EmojiEnum.Annoyed)
                        .WithTitle("Module set!")
                        .WithDescription($"The module **{ModuleName}** is now **{(Active ? "enabled" : "disabled")}.**")
                        .SendEmbed(Context.Channel);
                    }
                    break;
                }
            }
            else
            {
                await BuildEmbed(EmojiEnum.Annoyed)
                .WithTitle("Unknown Module!")
                .WithDescription($"I don't know a module called **{ModuleName}.**")
                .SendEmbed(Context.Channel);
            }
        }
Ejemplo n.º 3
0
        public static List <ModuleAction> GetModuleActions()
        {
            var moduleActions = new List <ModuleAction>();
            var viewType      = new ModuleActionType
            {
                Id          = Guid.Parse("72366792-3740-4E6B-B960-9C9C5334163A"),
                ControlType = "View"
            };

            var editType = new ModuleActionType
            {
                Id          = Guid.Parse("192278B6-7BF2-40C2-A776-B9CA5FB04FBB"),
                ControlType = "Edit"
            };

            moduleActions.Add(new ModuleAction()
            {
                Id                  = Guid.NewGuid(),
                ActionName          = "Login",
                ControllerName      = "Account",
                ControllerNamespace = "Deviser.Modules.Security.Controllers",
                DisplayName         = "Login",
                IconClass           = "fa fa-sign-in",
                ModuleActionType    = viewType
            });

            moduleActions.Add(new ModuleAction()
            {
                Id                  = Guid.NewGuid(),
                ActionName          = "Index",
                ControllerName      = "Home",
                ControllerNamespace = "Deviser.Modules.Language.Controllers",
                DisplayName         = "Register",
                IconClass           = "fa fa-language",
                ModuleActionType    = editType
            });

            return(moduleActions);
        }