Skip to content

Commit

Permalink
Threads inherit permissions from the channel in which they were creat…
Browse files Browse the repository at this point in the history
…ed (#759)
  • Loading branch information
valzargaming authored Mar 10, 2022
1 parent 0ea723d commit 570323b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Discord/Parts/User/Member.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Discord\Parts\Part;
use Discord\Parts\Permissions\Permission;
use Discord\Parts\Permissions\RolePermission;
use Discord\Parts\Thread\Thread;
use Discord\Parts\WebSockets\PresenceUpdate;
use React\Promise\ExtendedPromiseInterface;

Expand Down Expand Up @@ -301,12 +302,21 @@ public function sendMessage($message, bool $tts = false, $embed = null, $allowed
*
* @see https://discord.com/developers/docs/topics/permissions
*
* @param Channel|null $channel
* @param Channel|Thread|null $channel
*
* @throws \InvalidArgumentException
*
* @return RolePermission
*/
public function getPermissions(?Channel $channel = null): RolePermission
public function getPermissions($channel = null): RolePermission
{
if ($channel) {
if ($channel instanceof Thread) {
$channel = $this->guild->channels->get('id', $channel->parent_id);
} elseif (!($channel instanceof Channel)) {
throw new \InvalidArgumentException('$channel must be an instance of Channel, Thread or null.');
}
}
// Get @everyone role guild permission
$bitwise = $this->guild->roles->get('id', $this->guild_id)->permissions->bitwise;

Expand Down

0 comments on commit 570323b

Please sign in to comment.