public override string TryToExecute(CommandReceivedEventArgs eventArgs)
        {
            var word         = eventArgs?.Arguments?.ElementAtOrDefault(1)?.ToLowerInvariant();
            var newAlias     = eventArgs?.Arguments?.ElementAtOrDefault(2)?.ToLowerInvariant();
            var typeName     = _repository.Single(CommandWordPolicy.ByWord(word))?.FullTypeName;
            var existingWord = _repository.Single(CommandWordPolicy.ByWord(newAlias));

            if (string.IsNullOrEmpty(newAlias))
            {
                return("You seem to be missing the new alias you want to set.");
            }

            if (existingWord != null)
            {
                return($"The command word '!{existingWord.CommandWord}' already exists.");
            }

            var newCommand = new CommandWordEntity
            {
                CommandWord  = newAlias,
                FullTypeName = typeName,
                IsPrimary    = false
            };

            _repository.Create(newCommand);

            return($"Created new command alias '!{newAlias}' for '!{word}'.");
        }
        protected override void HandleCommand(IChatClient chatClient, CommandReceivedEventArgs eventArgs)
        {
            var oper = eventArgs?.Arguments?.ElementAtOrDefault(0)?.ToLowerInvariant();
            var word = eventArgs?.Arguments?.ElementAtOrDefault(1)?.ToLowerInvariant();

            if (string.IsNullOrEmpty(oper) || string.IsNullOrEmpty(word))
            {
                chatClient.SendMessage(HelpText);
                return;
            }

            var typeName = Repository.Single(CommandWordPolicy.ByWord(word))?.FullTypeName;

            if (typeName == null)
            {
                chatClient.SendMessage($"The command '!{word}' doesn't exist.");
                return;
            }

            var operationToUse = _operations.SingleOrDefault(x => x.ShouldExecute(oper));

            if (operationToUse != null)
            {
                string resultMessage = operationToUse.TryToExecute(eventArgs);
                chatClient.SendMessage(resultMessage);
                CommandAliasModified?.Invoke(this, EventArgs.Empty);
            }
            else
            {
                chatClient.SendMessage(HelpText);
            }
        }
        public override string TryToExecute(CommandReceivedEventArgs eventArgs)
        {
            if (eventArgs?.Arguments == null ||
                eventArgs.Arguments.Count < 3)
            {
                return(HelpText);
            }

            var word      = eventArgs.Arguments[1].ToLowerInvariant();
            var newAlias  = eventArgs.Arguments[2].ToLowerInvariant();
            var arguments = eventArgs.Arguments.Skip(3).ToList();

            var typeName     = _repository.Single(CommandWordPolicy.ByWord(word))?.FullTypeName;
            var existingWord = _repository.Single(CommandWordPolicy.ByWord(newAlias));

            if (string.IsNullOrEmpty(newAlias))
            {
                return("You seem to be missing the new alias you want to set.");
            }

            if (existingWord != null)
            {
                return($"The command word '!{existingWord.CommandWord}' already exists.");
            }

            var newCommand = new CommandWordEntity
            {
                CommandWord  = newAlias,
                FullTypeName = typeName,
                IsPrimary    = false
            };

            for (int i = 0; i < arguments.Count; i++)
            {
                newCommand.Arguments.Add(new AliasArgumentEntity
                {
                    Argument          = arguments[i],
                    CommandWordEntity = newCommand,
                    Index             = i
                });
            }

            _repository.Create(newCommand);

            return($"Created new command alias '!{newAlias}' for '!{word}'.");
        }
        public override string TryToExecute(CommandReceivedEventArgs eventArgs)
        {
            var word = eventArgs?.Arguments?.ElementAtOrDefault(1)?.ToLowerInvariant();

            var existingWord = _repository.Single(CommandWordPolicy.ByWord(word));

            if (existingWord == null)
            {
                return($"The command word '!{word}' doesn't exist.");
            }

            if (existingWord.IsPrimary)
            {
                return("The primary command cannot be deleted.");
            }

            _repository.Remove(existingWord);

            return($"The command '!{existingWord.CommandWord}' has been deleted.");
        }