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

feat(GuildMember): add method to check timeout #7146

Merged
merged 5 commits into from Dec 29, 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
11 changes: 11 additions & 0 deletions src/structures/GuildMember.js
Expand Up @@ -302,6 +302,17 @@ class GuildMember extends Base {
return this.manageable && (this.guild.me?.permissions.has(Permissions.FLAGS.MODERATE_MEMBERS) ?? false);
}

/**
* Whether this member is already under time out
iShibi marked this conversation as resolved.
Show resolved Hide resolved
* @returns {boolean}
*/
isTimedOut() {
iShibi marked this conversation as resolved.
Show resolved Hide resolved
return (
typeof this.communicationDisabledUntilTimestamp === 'number' &&
iShibi marked this conversation as resolved.
Show resolved Hide resolved
this.communicationDisabledUntilTimestamp > Date.now()
);
}
iShibi marked this conversation as resolved.
Show resolved Hide resolved

/**
* Returns `channel.permissionsFor(guildMember)`. Returns permissions for a member in a guild channel,
* taking into account roles and permission overwrites.
Expand Down
11 changes: 8 additions & 3 deletions typings/index.d.ts
Expand Up @@ -469,9 +469,10 @@ export type KeyedEnum<K, T> = {
[Key in keyof K]: T | string;
};

export type EnumValueMapped<E extends KeyedEnum<T, number>, T extends Partial<Record<keyof E, unknown>>> = T & {
[Key in keyof T as E[Key]]: T[Key];
};
export type EnumValueMapped<E extends KeyedEnum<T, number>, T extends Partial<Record<keyof E, unknown>>> = T &
{
[Key in keyof T as E[Key]]: T[Key];
};

export type MappedChannelCategoryTypes = EnumValueMapped<
typeof ChannelTypes,
Expand Down Expand Up @@ -1122,6 +1123,10 @@ export class GuildMember extends PartialTextBasedChannel(Base) {
public deleteDM(): Promise<DMChannel>;
public displayAvatarURL(options?: ImageURLOptions): string;
public edit(data: GuildMemberEditData, reason?: string): Promise<GuildMember>;
public isTimedOut(): this is GuildMember & {
communicationDisabledUntilTimestamp: number;
communicationDisabledUntil: Date;
iShibi marked this conversation as resolved.
Show resolved Hide resolved
};
public kick(reason?: string): Promise<GuildMember>;
public permissionsIn(channel: GuildChannelResolvable): Readonly<Permissions>;
public setNickname(nickname: string | null, reason?: string): Promise<GuildMember>;
Expand Down