From baacd6ba6979f11e1af38804df15468c29ec09e3 Mon Sep 17 00:00:00 2001 From: Shubham Parihar Date: Wed, 29 Dec 2021 15:22:15 +0530 Subject: [PATCH] feat(GuildMember): add method to check timeout (#7146) Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> Co-authored-by: Vlad Frangu --- src/structures/GuildMember.js | 8 ++++++++ typings/index.d.ts | 11 ++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/structures/GuildMember.js b/src/structures/GuildMember.js index 3837c139fbb2..f271def0e169 100644 --- a/src/structures/GuildMember.js +++ b/src/structures/GuildMember.js @@ -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. diff --git a/typings/index.d.ts b/typings/index.d.ts index 8a111cf47d8d..186ba0ffdbc5 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -469,9 +469,10 @@ export type KeyedEnum = { [Key in keyof K]: T | string; }; -export type EnumValueMapped, T extends Partial>> = T & { - [Key in keyof T as E[Key]]: T[Key]; -}; +export type EnumValueMapped, T extends Partial>> = T & + { + [Key in keyof T as E[Key]]: T[Key]; + }; export type MappedChannelCategoryTypes = EnumValueMapped< typeof ChannelTypes, @@ -1122,6 +1123,10 @@ export class GuildMember extends PartialTextBasedChannel(Base) { public deleteDM(): Promise; public displayAvatarURL(options?: ImageURLOptions): string; public edit(data: GuildMemberEditData, reason?: string): Promise; + public isCommunicationDisabled(): this is GuildMember & { + communicationDisabledUntilTimestamp: number; + readonly communicationDisabledUntil: Date; + }; public kick(reason?: string): Promise; public permissionsIn(channel: GuildChannelResolvable): Readonly; public setNickname(nickname: string | null, reason?: string): Promise;