Skip to content

Commit

Permalink
feat(GuildMember): add method to check timeout (#7146)
Browse files Browse the repository at this point in the history
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
  • Loading branch information
3 people committed Dec 29, 2021
1 parent 1391c36 commit baacd6b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/structures/GuildMember.js
Expand Up @@ -303,6 +303,14 @@ class GuildMember extends Base {
return this.manageable && (this.guild.me?.permissions.has(Permissions.FLAGS.MODERATE_MEMBERS) ?? false);
}

/**
* Whether this member is currently timed out
* @returns {boolean}
*/
isCommunicationDisabled() {
return this.communicationDisabledUntilTimestamp > Date.now();
}

/**
* 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 isCommunicationDisabled(): this is GuildMember & {
communicationDisabledUntilTimestamp: number;
readonly communicationDisabledUntil: Date;
};
public kick(reason?: string): Promise<GuildMember>;
public permissionsIn(channel: GuildChannelResolvable): Readonly<Permissions>;
public setNickname(nickname: string | null, reason?: string): Promise<GuildMember>;
Expand Down

0 comments on commit baacd6b

Please sign in to comment.