Beispiel #1
0
        private async Task TryRunAsBotCommand(SocketCommandContext context, int argPos)
        {
            var cmdSearchResult = _commandService.Search(context, argPos);

            if (cmdSearchResult.Commands.Count == 0)
            {
                CheckIfDoubleSpace(context);
                return;
            }

            Logger.Log($"[Command] {context.User.Username} is running '{cmdSearchResult.Commands.FirstOrDefault().Command.Name}' - Full message: '{context.Message.Content}'");

            var commandTask = _commandService.ExecuteAsync(context, argPos, _services);

            #pragma warning disable CS4014
            commandTask.ContinueWith(task =>
            {
                if (!task.Result.IsSuccess)
                {
                    var exceptionMessage = _lang.FromTemplate("EXCEPTION_RESPONSE_TEMPLATE(@REASON)", objects: task.Result.ErrorReason);
                    context.Channel.SendMessageAsync(exceptionMessage);
                }
            });
            #pragma warning restore CS4014
        }