mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
fix: don't patch missing properties from partial payloads (#5796)
* fix: don't patch missing properties from partial payloads * fix(GuildChannel): initialize permissionOverwrites in the constructor * refactor(GuildChannel): remove redundant if
This commit is contained in:
@@ -35,35 +35,44 @@ class GuildChannel extends Channel {
|
||||
* @type {Guild}
|
||||
*/
|
||||
this.guild = guild;
|
||||
|
||||
this.parentID = null;
|
||||
this.permissionOverwrites = new Collection();
|
||||
}
|
||||
|
||||
_patch(data) {
|
||||
super._patch(data);
|
||||
|
||||
/**
|
||||
* The name of the guild channel
|
||||
* @type {string}
|
||||
*/
|
||||
this.name = data.name;
|
||||
if ('name' in data) {
|
||||
/**
|
||||
* The name of the guild channel
|
||||
* @type {string}
|
||||
*/
|
||||
this.name = data.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The raw position of the channel from discord
|
||||
* @type {number}
|
||||
*/
|
||||
this.rawPosition = data.position;
|
||||
if ('position' in data) {
|
||||
/**
|
||||
* The raw position of the channel from discord
|
||||
* @type {number}
|
||||
*/
|
||||
this.rawPosition = data.position;
|
||||
}
|
||||
|
||||
/**
|
||||
* The ID of the category parent of this channel
|
||||
* @type {?Snowflake}
|
||||
*/
|
||||
this.parentID = data.parent_id || null;
|
||||
if ('parent_id' in data) {
|
||||
/**
|
||||
* The ID of the category parent of this channel
|
||||
* @type {?Snowflake}
|
||||
*/
|
||||
this.parentID = data.parent_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* A map of permission overwrites in this channel for roles and users
|
||||
* @type {Collection<Snowflake, PermissionOverwrites>}
|
||||
*/
|
||||
this.permissionOverwrites = new Collection();
|
||||
if (data.permission_overwrites) {
|
||||
if ('permission_overwrites' in data) {
|
||||
/**
|
||||
* A map of permission overwrites in this channel for roles and users
|
||||
* @type {Collection<Snowflake, PermissionOverwrites>}
|
||||
*/
|
||||
this.permissionOverwrites = new Collection();
|
||||
for (const overwrite of data.permission_overwrites) {
|
||||
this.permissionOverwrites.set(overwrite.id, new PermissionOverwrites(this, overwrite));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user