mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 03:23:29 +01:00
feat(channel): add isDMBased typeguard (#7362)
This commit is contained in:
@@ -181,6 +181,14 @@ class Channel extends Base {
|
|||||||
return 'messages' in this;
|
return 'messages' in this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether this channel is DM-based (either a {@link DMChannel} or a {@link GroupDMChannel}).
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
isDMBased() {
|
||||||
|
return [ChannelType.DM, ChannelType.GroupDM].includes(this.type);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates whether this channel is {@link BaseGuildVoiceChannel voice-based}.
|
* Indicates whether this channel is {@link BaseGuildVoiceChannel voice-based}.
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
|
|||||||
2
packages/discord.js/typings/index.d.ts
vendored
2
packages/discord.js/typings/index.d.ts
vendored
@@ -503,6 +503,7 @@ export abstract class Channel extends Base {
|
|||||||
public isThread(): this is ThreadChannel;
|
public isThread(): this is ThreadChannel;
|
||||||
public isStage(): this is StageChannel;
|
public isStage(): this is StageChannel;
|
||||||
public isTextBased(): this is TextBasedChannel;
|
public isTextBased(): this is TextBasedChannel;
|
||||||
|
public isDMBased(): this is PartialGroupDMChannel | DMChannel;
|
||||||
public isVoiceBased(): this is VoiceBasedChannel;
|
public isVoiceBased(): this is VoiceBasedChannel;
|
||||||
public toString(): ChannelMention;
|
public toString(): ChannelMention;
|
||||||
}
|
}
|
||||||
@@ -1688,6 +1689,7 @@ export class OAuth2Guild extends BaseGuild {
|
|||||||
|
|
||||||
export class PartialGroupDMChannel extends Channel {
|
export class PartialGroupDMChannel extends Channel {
|
||||||
private constructor(client: Client, data: RawPartialGroupDMChannelData);
|
private constructor(client: Client, data: RawPartialGroupDMChannelData);
|
||||||
|
public type: ChannelType.GroupDM;
|
||||||
public name: string | null;
|
public name: string | null;
|
||||||
public icon: string | null;
|
public icon: string | null;
|
||||||
public recipients: PartialRecipient[];
|
public recipients: PartialRecipient[];
|
||||||
|
|||||||
Reference in New Issue
Block a user