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>
This commit is contained in:
Shubham Parihar
2021-12-29 15:22:15 +05:30
committed by GitHub
parent 1391c363e5
commit baacd6ba69
2 changed files with 16 additions and 3 deletions

View File

@@ -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.

11
typings/index.d.ts vendored
View File

@@ -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,
@@ -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>;