1
0
mirror of https://github.com/oliverbooth/VpSharp synced 2024-11-09 23:15:41 +00:00

fix(commands): swap out unreferenced MessageReceivedEventArgs

This commit is contained in:
Oliver Booth 2023-05-08 15:44:06 +01:00
parent ee005f30a8
commit 1f761668f7
No known key found for this signature in database
GPG Key ID: 20BEB9DC87961025

View File

@ -162,14 +162,13 @@ public sealed class CommandsExtension : VirtualParadiseClientExtension
} }
/// <inheritdoc /> /// <inheritdoc />
protected internal override Task OnMessageReceived(MessageReceivedEventArgs args) protected internal override Task OnMessageReceived(VirtualParadiseMessage message)
{ {
ArgumentNullException.ThrowIfNull(args); ArgumentNullException.ThrowIfNull(message);
VirtualParadiseMessage message = args.Message;
if (message.Type != MessageType.ChatMessage) if (message.Type != MessageType.ChatMessage)
{ {
return base.OnMessageReceived(args); return base.OnMessageReceived(message);
} }
foreach (ReadOnlySpan<char> prefix in _configuration.Prefixes) foreach (ReadOnlySpan<char> prefix in _configuration.Prefixes)
@ -197,7 +196,7 @@ public sealed class CommandsExtension : VirtualParadiseClientExtension
var commandNameString = commandName.ToString(); var commandNameString = commandName.ToString();
if (!_commandMap.TryGetValue(commandNameString, out Command? command)) if (!_commandMap.TryGetValue(commandNameString, out Command? command))
{ {
return base.OnMessageReceived(args); return base.OnMessageReceived(message);
} }
var context = new CommandContext(Client, message.Author, command.Name, commandNameString, rawArguments.ToString()); var context = new CommandContext(Client, message.Author, command.Name, commandNameString, rawArguments.ToString());
@ -207,7 +206,7 @@ public sealed class CommandsExtension : VirtualParadiseClientExtension
{ {
if (!attribute.PerformAsync(context).ConfigureAwait(false).GetAwaiter().GetResult()) if (!attribute.PerformAsync(context).ConfigureAwait(false).GetAwaiter().GetResult())
{ {
return base.OnMessageReceived(args); return base.OnMessageReceived(message);
} }
} }
@ -255,7 +254,7 @@ public sealed class CommandsExtension : VirtualParadiseClientExtension
ParameterInfo[] parameters = commandMethod.GetParameters(); ParameterInfo[] parameters = commandMethod.GetParameters();
if (parameters.Length != arguments.Length || parameters[arguments.Length..].Any(p => !p.IsOptional)) if (parameters.Length != arguments.Length || parameters[arguments.Length..].Any(p => !p.IsOptional))
{ {
return base.OnMessageReceived(args); return base.OnMessageReceived(message);
} }
for (var index = 0; index < arguments.Length; index++) for (var index = 0; index < arguments.Length; index++)
@ -297,10 +296,10 @@ public sealed class CommandsExtension : VirtualParadiseClientExtension
return task; return task;
} }
return base.OnMessageReceived(args); return base.OnMessageReceived(message);
} }
return base.OnMessageReceived(args); return base.OnMessageReceived(message);
} }
private void RegisterCommandMethod(CommandModule module, MethodInfo methodInfo) private void RegisterCommandMethod(CommandModule module, MethodInfo methodInfo)