Skip to content

Commit baacd6b

Browse files
iShibiJiralitevladfrangu
authoredDec 29, 2021
feat(GuildMember): add method to check timeout (#7146)
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
1 parent 1391c36 commit baacd6b

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed
 

‎src/structures/GuildMember.js

+8
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,14 @@ class GuildMember extends Base {
303303
return this.manageable && (this.guild.me?.permissions.has(Permissions.FLAGS.MODERATE_MEMBERS) ?? false);
304304
}
305305

306+
/**
307+
* Whether this member is currently timed out
308+
* @returns {boolean}
309+
*/
310+
isCommunicationDisabled() {
311+
return this.communicationDisabledUntilTimestamp > Date.now();
312+
}
313+
306314
/**
307315
* Returns `channel.permissionsFor(guildMember)`. Returns permissions for a member in a guild channel,
308316
* taking into account roles and permission overwrites.

‎typings/index.d.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,10 @@ export type KeyedEnum<K, T> = {
469469
[Key in keyof K]: T | string;
470470
};
471471

472-
export type EnumValueMapped<E extends KeyedEnum<T, number>, T extends Partial<Record<keyof E, unknown>>> = T & {
473-
[Key in keyof T as E[Key]]: T[Key];
474-
};
472+
export type EnumValueMapped<E extends KeyedEnum<T, number>, T extends Partial<Record<keyof E, unknown>>> = T &
473+
{
474+
[Key in keyof T as E[Key]]: T[Key];
475+
};
475476

476477
export type MappedChannelCategoryTypes = EnumValueMapped<
477478
typeof ChannelTypes,
@@ -1122,6 +1123,10 @@ export class GuildMember extends PartialTextBasedChannel(Base) {
11221123
public deleteDM(): Promise<DMChannel>;
11231124
public displayAvatarURL(options?: ImageURLOptions): string;
11241125
public edit(data: GuildMemberEditData, reason?: string): Promise<GuildMember>;
1126+
public isCommunicationDisabled(): this is GuildMember & {
1127+
communicationDisabledUntilTimestamp: number;
1128+
readonly communicationDisabledUntil: Date;
1129+
};
11251130
public kick(reason?: string): Promise<GuildMember>;
11261131
public permissionsIn(channel: GuildChannelResolvable): Readonly<Permissions>;
11271132
public setNickname(nickname: string | null, reason?: string): Promise<GuildMember>;

0 commit comments

Comments
 (0)
Please sign in to comment.