public override Task ProcessAsync(CommandProcessorInput input)
        {
            if (!_config.PrefixIsSet)
            {
                return(NextStep.ProcessAsync(input));
            }

            if (input.Message.StartsWith(_config.CommandPrefix))
            {
                input.PrefixOffset = (uint)_config.CommandPrefix.Length;
                return(NextStep.ProcessAsync(input));
            }

            return(Task.CompletedTask);
        }
        public override Task ProcessAsync(CommandProcessorInput input)
        {
            var commands = _serviceCollection.GetAvailableCommands();

            if (commands is null || !commands.Any())
            {
                _logWriter.Log("Service Location did not get any available commands.");
                return(Task.CompletedTask);
            }

            var prompt = input.Message.Substring((int)input.PrefixOffset).Trim();

            input.TargetedCommands = commands.Where(c => prompt.StartsWith(c.Prompt));
            return(NextStep.ProcessAsync(input));
        }
Exemple #3
0
        private Task ProcessMessageAsync(SocketMessage s)
        {
            if (s is SocketUserMessage msg)
            {
                var input = new CommandProcessorInput
                {
                    Message   = msg.Content,
                    MessageId = msg.Id,
                    ChannelId = msg.Channel.Id,
                    GuildId   = (msg.Author as SocketGuildUser)?.Guild.Id
                };

                return(_commandProcessor.ProcessAsync(input));
            }

            return(Task.CompletedTask);
        }
Exemple #4
0
 private bool GetInputMatchesCommands(CommandProcessorInput i, string[] commands)
 => i.TargetedCommands.Select(c => c.Prompt).SequenceEqual(commands);