fix(GuildManager): add missing types and converts (#6683)

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
This commit is contained in:
Nyan Spaghetti
2021-10-02 20:42:10 +09:00
committed by GitHub
parent a7cb314e07
commit cdf65f74e1
2 changed files with 37 additions and 4 deletions

View File

@@ -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();
}