Merge pull request #677 from Cyberboss/FixChat

Fix crashing while processing unknown chat commands
This commit is contained in:
Jordan Brown
2018-09-18 23:51:35 -04:00
committed by GitHub
@@ -269,18 +269,18 @@ namespace Tgstation.Server.Host.Components.Chat
var commandHandler = await GetCommand(command).ConfigureAwait(false);
if (commandHandler.AdminOnly && !message.User.Channel.IsAdmin)
{
await SendMessage("Use this command in an admin channel!", new List<ulong> { message.User.Channel.RealId }, cancellationToken).ConfigureAwait(false);
return;
}
if (commandHandler == default)
{
await SendMessage(UnknownCommandMessage, new List<ulong> { message.User.Channel.RealId }, cancellationToken).ConfigureAwait(false);
return;
}
if (commandHandler.AdminOnly && !message.User.Channel.IsAdmin)
{
await SendMessage("Use this command in an admin channel!", new List<ulong> { message.User.Channel.RealId }, cancellationToken).ConfigureAwait(false);
return;
}
var result = await commandHandler.Invoke(arguments, message.User, cancellationToken).ConfigureAwait(false);
if (result != null)
await SendMessage(result, new List<ulong> { message.User.Channel.RealId }, cancellationToken).ConfigureAwait(false);