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(GuildManager): add missing types and converts #6683

Merged
merged 4 commits into from Oct 2, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/managers/GuildManager.js
Expand Up @@ -12,6 +12,7 @@ const Role = require('../structures/Role');
const {
ChannelTypes,
Events,
OverwriteTypes,
VerificationLevels,
DefaultMessageNotificationLevels,
ExplicitContentFilterLevels,
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -190,8 +191,15 @@ class GuildManager extends CachedManager {
if (channel.type) channel.type = ChannelTypes[channel.type.toUpperCase()];
NyanSpaghetti marked this conversation as resolved.
Show resolved Hide resolved
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();
}
Expand Down
8 changes: 6 additions & 2 deletions typings/index.d.ts
Expand Up @@ -4508,11 +4508,15 @@ export type PresenceResolvable = Presence | UserResolvable | Snowflake;

export interface PartialChannelData {
id?: Snowflake | number;
parentId?: Snowflake | number;
type?: ChannelTypes;
NyanSpaghetti marked this conversation as resolved.
Show resolved Hide resolved
name: string;
topic?: string;
type?: ChannelTypes;
parentId?: Snowflake | number;
nsfw?: boolean;
bitrate?: number;
userLimit?: number;
permissionOverwrites?: PartialOverwriteData[];
rateLimitPerUser?: number;
}

export type Partialize<
Expand Down