Skip to content

Avoid stacktrace when bots send commands #133

Description

@arancaytar

Relevant part of the stacktrace

/home/keira/bots/huntress/vendor/sylae/huntress/src/Huntress/Permission.php:290

Huntress\Permission::filterRole(): Argument #1 ($target) must be of type CharlotteDunois\Yasmin\Models\GuildMember, CharlotteDunois\Yasmin\Models\User given, called in /home/keira/bots/huntress/vendor/sylae/huntress/src/Huntress/Permission.php on line 217

#0 /home/keira/bots/huntress/vendor/sylae/huntress/src/Huntress/Permission.php(217): Huntress\Permission->filterRole()
#1 /home/keira/bots/huntress/vendor/sylae/huntress/src/Huntress/Permission.php(156): Huntress\Permission->check()
#2 /home/keira/bots/huntress/src/Huntress/Plugin/Role.php(113): Huntress\Permission->resolve()

It looks like the assumption is that $this->context->user (when passed to Permission::filterRole()) is a GuildMember. But it's a bit odd, because in Permission::sendUnauthorizedMessage() that type is explicitly checked.

Specifically, this came up in a case where a !role command was proxied, which can't work in any case.

So I guess some of our options here are to:

  • ignore commands from bots entirely
  • specifically ignore !role commands from bots (since these would target the bot and not the user that was proxied)
  • make Permission::resolve() (or an earlier function in Permission) check the type of the EventData;:$user variable and reject if it's not a GuildMember?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions