mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 20:13:30 +01:00
feat(Channel): add isThread typeguard for better TS support (#5978)
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const Base = require('./Base');
|
const Base = require('./Base');
|
||||||
const { ChannelTypes } = require('../util/Constants');
|
const { ChannelTypes, ThreadChannelTypes } = require('../util/Constants');
|
||||||
const SnowflakeUtil = require('../util/SnowflakeUtil');
|
const SnowflakeUtil = require('../util/SnowflakeUtil');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,6 +110,14 @@ class Channel extends Base {
|
|||||||
return 'messages' in this;
|
return 'messages' in this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether this channel is a thread channel.
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
isThread() {
|
||||||
|
return ThreadChannelTypes.includes(this.type);
|
||||||
|
}
|
||||||
|
|
||||||
static create(client, data, guild) {
|
static create(client, data, guild) {
|
||||||
const Structures = require('../util/Structures');
|
const Structures = require('../util/Structures');
|
||||||
let channel;
|
let channel;
|
||||||
|
|||||||
1
typings/index.d.ts
vendored
1
typings/index.d.ts
vendored
@@ -438,6 +438,7 @@ declare module 'discord.js' {
|
|||||||
public delete(reason?: string): Promise<Channel>;
|
public delete(reason?: string): Promise<Channel>;
|
||||||
public fetch(force?: boolean): Promise<Channel>;
|
public fetch(force?: boolean): Promise<Channel>;
|
||||||
public isText(): this is TextChannel | DMChannel | NewsChannel | ThreadChannel;
|
public isText(): this is TextChannel | DMChannel | NewsChannel | ThreadChannel;
|
||||||
|
public isThread(): this is ThreadChannel;
|
||||||
public toString(): string;
|
public toString(): string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user