Skip to content

Commit

Permalink
Temporary fix for cached interaction->member->permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
SQKo committed Sep 18, 2022
1 parent 471020e commit 8480a4d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Discord/Parts/Interactions/Interaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,14 @@ protected function getChannelAttribute(): ?Channel
protected function getMemberAttribute(): ?Member
{
if (isset($this->attributes['member'])) {
if ($this->guild && $member = $this->guild->members->get('id', $this->attributes['member']->user->id)) {
return $member;
if ($guild = $this->guild) {
if ($member = $guild->members->get('id', $this->attributes['member']->user->id)) {
// @todo Temporary workaround until member is cached from INTERACTION_CREATE event
if (! $member->permissions) {
$member->permissions = $this->attributes['member']->permissions;
}
return $member;
}
}

return $this->factory->create(Member::class, (array) $this->attributes['member'] + ['guild_id' => $this->guild_id], true);
Expand Down

0 comments on commit 8480a4d

Please sign in to comment.