Skip to content

Commit

Permalink
Fix permissionsOf when run in stage channels
Browse files Browse the repository at this point in the history
  • Loading branch information
bsian03 committed Aug 17, 2021
1 parent 29a5ca8 commit 083f94e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/structures/GuildChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const Collection = require("../util/Collection");
const Permission = require("./Permission");
const {Permissions} = require("../Constants");
const PermissionOverwrite = require("./PermissionOverwrite");
const ThreadChannel = require("./ThreadChannel");

/**
* Represents a guild channel. You also probably want to look at CategoryChannel, NewsChannel, StoreChannel, TextChannel, and VoiceChannel. See Channel for extra properties.
Expand Down Expand Up @@ -127,20 +128,21 @@ class GuildChannel extends Channel {
if(permission & Permissions.administrator) {
return new Permission(Permissions.all);
}
let overwrite = this.permissionOverwrites.get(this.guild.id);
const channel = this instanceof ThreadChannel ? this.guild.channels.get(this.parentID) : this;
let overwrite = channel && channel.permissionOverwrites.get(this.guild.id);
if(overwrite) {
permission = (permission & ~overwrite.deny) | overwrite.allow;
}
let deny = 0n;
let allow = 0n;
for(const roleID of member.roles) {
if((overwrite = this.permissionOverwrites.get(roleID))) {
if((overwrite = channel && channel.permissionOverwrites.get(roleID))) {
deny |= overwrite.deny;
allow |= overwrite.allow;
}
}
permission = (permission & ~deny) | allow;
overwrite = this.permissionOverwrites.get(member.id);
overwrite = channel && channel.permissionOverwrites.get(member.id);
if(overwrite) {
permission = (permission & ~overwrite.deny) | overwrite.allow;
}
Expand Down

0 comments on commit 083f94e

Please sign in to comment.