diff --git a/src/managers/GuildManager.js b/src/managers/GuildManager.js index 895eb536835a..fa536e3c51a9 100644 --- a/src/managers/GuildManager.js +++ b/src/managers/GuildManager.js @@ -12,6 +12,7 @@ const Role = require('../structures/Role'); const { ChannelTypes, Events, + OverwriteTypes, VerificationLevels, DefaultMessageNotificationLevels, ExplicitContentFilterLevels, @@ -73,7 +74,7 @@ class GuildManager extends CachedManager { * Partial overwrite data. * @typedef {Object} PartialOverwriteData * @property {Snowflake|number} id The id of the {@link Role} or {@link User} this overwrite belongs to - * @property {string} [type] The type of this overwrite + * @property {OverwriteType} [type] The type of this overwrite * @property {PermissionResolvable} [allow] The permissions to allow * @property {PermissionResolvable} [deny] The permissions to deny */ @@ -84,7 +85,7 @@ class GuildManager extends CachedManager { * @property {Snowflake|number} [id] The channel's id, used to set its parent, * this is a placeholder and will be replaced by the API after consumption * @property {Snowflake|number} [parentId] The parent id for this channel - * @property {ChannelType} [type] The type of the channel + * @property {ChannelType|number} [type] The type of the channel * @property {string} name The name of the channel * @property {string} [topic] The topic of the text channel * @property {boolean} [nsfw] Whether the channel is NSFW @@ -188,10 +189,18 @@ class GuildManager extends CachedManager { } for (const channel of channels) { if (channel.type) channel.type = ChannelTypes[channel.type.toUpperCase()]; + if (channel.type) channel.type = typeof channel.type === 'number' ? channel.type : ChannelTypes[channel.type]; channel.parent_id = channel.parentId; delete channel.parentId; + channel.user_limit = channel.userLimit; + delete channel.userLimit; + channel.rate_limit_per_user = channel.rateLimitPerUser; + delete channel.rateLimitPerUser; if (!channel.permissionOverwrites) continue; for (const overwrite of channel.permissionOverwrites) { + if (typeof overwrite.type === 'string') { + overwrite.type = OverwriteTypes[overwrite.type]; + } if (overwrite.allow) overwrite.allow = Permissions.resolve(overwrite.allow).toString(); if (overwrite.deny) overwrite.deny = Permissions.resolve(overwrite.deny).toString(); } diff --git a/typings/index.d.ts b/typings/index.d.ts index fda36b575539..9770d48bccfe 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -4563,11 +4563,35 @@ export type PresenceResolvable = Presence | UserResolvable | Snowflake; export interface PartialChannelData { id?: Snowflake | number; + parentId?: Snowflake | number; + type?: Exclude< + keyof typeof ChannelTypes | ChannelTypes, + | 'DM' + | 'GROUP_DM' + | 'GUILD_NEWS' + | 'GUILD_STORE' + | 'UNKNOWN' + | 'GUILD_NEWS_THREAD' + | 'GUILD_PUBLIC_THREAD' + | 'GUILD_PRIVATE_THREAD' + | 'GUILD_STAGE_VOICE' + | ChannelTypes.DM + | ChannelTypes.GROUP_DM + | ChannelTypes.GUILD_NEWS + | ChannelTypes.GUILD_STORE + | ChannelTypes.UNKNOWN + | ChannelTypes.GUILD_NEWS_THREAD + | ChannelTypes.GUILD_PUBLIC_THREAD + | ChannelTypes.GUILD_PRIVATE_THREAD + | ChannelTypes.GUILD_STAGE_VOICE + >; name: string; topic?: string; - type?: ChannelTypes; - parentId?: Snowflake | number; + nsfw?: boolean; + bitrate?: number; + userLimit?: number; permissionOverwrites?: PartialOverwriteData[]; + rateLimitPerUser?: number; } export type Partialize<