Beispiel #1
0
        public async Task DeactivateCommand(CommandEventArgs e)
        {
            try
            {
                ICommand command = CommandsManager.FindCommand(e.GetArg(CommandsConstants.ParameterCommandName), mBotModulesObserver.Modules);

                if (command.IsBlocked((long)e.Server.Id))
                {
                    await SendStyleMessage(e.Channel, SettingsModuleResource.CommandAlreadyBlocked, SettingsModuleResource.Markdown);
                }
                else
                {
                    BlockedCommandService.Instance.Repository.Add(new BlockedCommand {
                        CommandName = command.Name, GuildId = (long)e.Server.Id
                    });
                    await SendStyleMessage(e.Channel, String.Format(SettingsModuleResource.CommandBlocked, command.Name), SettingsModuleResource.Markdown);
                }
            }
            catch (ArgumentException exp)
            {
                await SendStyleMessage(e.Channel, exp.Message, SettingsModuleResource.Markdown);
            }
        }
Beispiel #2
0
        public async Task ActivateCommand(CommandEventArgs e)
        {
            try
            {
                ICommand command = CommandsManager.FindCommand(e.GetArg(CommandsConstants.ParameterCommandName), mBotModulesObserver.Modules);

                if (!command.IsBlocked((long)e.Server.Id))
                {
                    await SendStyleMessage(e.Channel, SettingsModuleResource.CommandAlreadyUnblocked, SettingsModuleResource.Markdown);
                }
                else
                {
                    var blockedCommandId = BlockedCommandService.Instance.Repository.GetByName(command.Name, (long)e.Server.Id).Id;
                    BlockedCommandService.Instance.Repository.RemoveById(blockedCommandId);

                    await SendStyleMessage(e.Channel, String.Format(SettingsModuleResource.CommandUnblocked, command.Name), SettingsModuleResource.Markdown);
                }
            }
            catch (ArgumentException exp)
            {
                await SendStyleMessage(e.Channel, exp.Message, SettingsModuleResource.Markdown);
            }
        }