Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(GuildChannel): Add missing 'cache' property #6019

Merged
merged 2 commits into from Jul 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/structures/GuildChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,15 @@ class GuildChannel extends Channel {
if (!this.parent) return null;

// Get all overwrites
const overwriteIds = new Set([...this.permissionOverwrites.keys(), ...this.parent.permissionOverwrites.keys()]);
const overwriteIds = new Set([
...this.permissionOverwrites.cache.keys(),
...this.parent.permissionOverwrites.cache.keys(),
]);

// Compare all overwrites
return [...overwriteIds].every(key => {
const channelVal = this.permissionOverwrites.get(key);
const parentVal = this.parent.permissionOverwrites.get(key);
const channelVal = this.permissionOverwrites.cache.get(key);
const parentVal = this.parent.permissionOverwrites.cache.get(key);

// Handle empty overwrite
if (
Expand Down Expand Up @@ -158,7 +161,7 @@ class GuildChannel extends Channel {
let memberOverwrites;
let everyoneOverwrites;

for (const overwrite of this.permissionOverwrites.values()) {
for (const overwrite of this.permissionOverwrites.cache.values()) {
if (overwrite.id === this.guild.id) {
everyoneOverwrites = overwrite;
} else if (roles.has(overwrite.id)) {
Expand Down Expand Up @@ -210,8 +213,8 @@ class GuildChannel extends Channel {
rolePermissions(role) {
if (role.permissions.has(Permissions.FLAGS.ADMINISTRATOR)) return new Permissions(Permissions.ALL).freeze();

const everyoneOverwrites = this.permissionOverwrites.get(this.guild.id);
const roleOverwrites = this.permissionOverwrites.get(role.id);
const everyoneOverwrites = this.permissionOverwrites.cache.get(this.guild.id);
const roleOverwrites = this.permissionOverwrites.cache.get(role.id);

return role.permissions
.remove(everyoneOverwrites?.deny ?? Permissions.defaultBit)
Expand Down Expand Up @@ -518,7 +521,7 @@ class GuildChannel extends Channel {
*/
clone(options = {}) {
return this.guild.channels.create(options.name ?? this.name, {
permissionOverwrites: this.permissionOverwrites,
permissionOverwrites: this.permissionOverwrites.cache,
topic: this.topic,
type: this.type,
nsfw: this.nsfw,
Expand Down Expand Up @@ -549,7 +552,7 @@ class GuildChannel extends Channel {

if (equal) {
if (this.permissionOverwrites && channel.permissionOverwrites) {
equal = this.permissionOverwrites.equals(channel.permissionOverwrites);
equal = this.permissionOverwrites.cache.equals(channel.permissionOverwrites.cache);
} else {
equal = !this.permissionOverwrites && !channel.permissionOverwrites;
}
Expand Down