Skip to content

Commit

Permalink
Fix commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Tides committed Jan 24, 2024
1 parent b265481 commit c01ded3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Obsidian/Commands/Builders/CommandBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ public CommandBuilder AddOverload(IExecutor<CommandContext> commandExecutor)
return this;
}

public CommandBuilder AddOverloads(params CommandExecutor[] executors)
public CommandBuilder AddOverloads(params IExecutor<CommandContext>[] executors)
{
this.overloads.AddRange(executors);

return this;
}

public CommandBuilder AddOverloads(IEnumerable<CommandExecutor> executors)
public CommandBuilder AddOverloads(IEnumerable<IExecutor<CommandContext>> executors)
{
this.overloads.AddRange(executors);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal sealed class CommandDelegateExecutor : IExecutor<CommandContext>

public required Delegate MethodDelegate { get; init; }

public ParameterInfo[] GetParameters() => this.MethodDelegate.Method.GetParameters();
public ParameterInfo[] GetParameters() => this.MethodDelegate.Method.GetParameters()[..1];

public IEnumerable<TAttribute> GetCustomAttributes<TAttribute>() where TAttribute : Attribute =>
this.MethodDelegate.Method.GetCustomAttributes<TAttribute>();
Expand Down
2 changes: 1 addition & 1 deletion Obsidian/Registries/CommandsRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static void Register(Server server)

foreach (var overload in cmd.Overloads)
{
var args = overload.HasModule ? overload.GetParameters() : overload.GetParameters().Skip(1); // skipping obsidian context
var args = overload.GetParameters();
if (!args.Any())
cmdNode.Type |= CommandNodeType.IsExecutable;

Expand Down

0 comments on commit c01ded3

Please sign in to comment.