mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-20 21:43:33 +01:00
feat: backport (#7777)
This commit is contained in:
@@ -10,6 +10,7 @@ let StoreChannel;
|
|||||||
let TextChannel;
|
let TextChannel;
|
||||||
let ThreadChannel;
|
let ThreadChannel;
|
||||||
let VoiceChannel;
|
let VoiceChannel;
|
||||||
|
let DirectoryChannel;
|
||||||
const { ChannelTypes, ThreadChannelTypes, VoiceBasedChannelTypes } = require('../util/Constants');
|
const { ChannelTypes, ThreadChannelTypes, VoiceBasedChannelTypes } = require('../util/Constants');
|
||||||
const SnowflakeUtil = require('../util/SnowflakeUtil');
|
const SnowflakeUtil = require('../util/SnowflakeUtil');
|
||||||
|
|
||||||
@@ -164,6 +165,14 @@ class Channel extends Base {
|
|||||||
return ThreadChannelTypes.includes(this.type);
|
return ThreadChannelTypes.includes(this.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether this channel is a {@link DirectoryChannel}
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
isDirectory() {
|
||||||
|
return this.type === 'GUILD_DIRECTORY';
|
||||||
|
}
|
||||||
|
|
||||||
static create(client, data, guild, { allowUnknownGuild, fromInteraction } = {}) {
|
static create(client, data, guild, { allowUnknownGuild, fromInteraction } = {}) {
|
||||||
CategoryChannel ??= require('./CategoryChannel');
|
CategoryChannel ??= require('./CategoryChannel');
|
||||||
DMChannel ??= require('./DMChannel');
|
DMChannel ??= require('./DMChannel');
|
||||||
@@ -173,6 +182,7 @@ class Channel extends Base {
|
|||||||
TextChannel ??= require('./TextChannel');
|
TextChannel ??= require('./TextChannel');
|
||||||
ThreadChannel ??= require('./ThreadChannel');
|
ThreadChannel ??= require('./ThreadChannel');
|
||||||
VoiceChannel ??= require('./VoiceChannel');
|
VoiceChannel ??= require('./VoiceChannel');
|
||||||
|
DirectoryChannel ??= require('./DirectoryChannel');
|
||||||
|
|
||||||
let channel;
|
let channel;
|
||||||
if (!data.guild_id && !guild) {
|
if (!data.guild_id && !guild) {
|
||||||
@@ -218,6 +228,10 @@ class Channel extends Base {
|
|||||||
if (!allowUnknownGuild) channel.parent?.threads.cache.set(channel.id, channel);
|
if (!allowUnknownGuild) channel.parent?.threads.cache.set(channel.id, channel);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case ChannelTypes.GUILD_DIRECTORY:
|
||||||
|
channel = new DirectoryChannel(client, data);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (channel && !allowUnknownGuild) guild.channels?.cache.set(channel.id, channel);
|
if (channel && !allowUnknownGuild) guild.channels?.cache.set(channel.id, channel);
|
||||||
}
|
}
|
||||||
|
|||||||
19
src/structures/DirectoryChannel.js
Normal file
19
src/structures/DirectoryChannel.js
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const { Channel } = require('./Channel');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a channel that displays a directory of guilds
|
||||||
|
*/
|
||||||
|
class DirectoryChannel extends Channel {
|
||||||
|
_patch(data) {
|
||||||
|
super._patch(data);
|
||||||
|
/**
|
||||||
|
* The channel's name
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
this.name = data.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = DirectoryChannel;
|
||||||
@@ -529,6 +529,7 @@ exports.ActivityTypes = createEnum(['PLAYING', 'STREAMING', 'LISTENING', 'WATCHI
|
|||||||
* * `GUILD_PUBLIC_THREAD` - a guild text channel's public thread channel
|
* * `GUILD_PUBLIC_THREAD` - a guild text channel's public thread channel
|
||||||
* * `GUILD_PRIVATE_THREAD` - a guild text channel's private thread channel
|
* * `GUILD_PRIVATE_THREAD` - a guild text channel's private thread channel
|
||||||
* * `GUILD_STAGE_VOICE` - a guild stage voice channel
|
* * `GUILD_STAGE_VOICE` - a guild stage voice channel
|
||||||
|
* * `GUILD_DIRECTORY` - the channel in a hub containing guilds
|
||||||
* * `UNKNOWN` - a generic channel of unknown type, could be Channel or GuildChannel
|
* * `UNKNOWN` - a generic channel of unknown type, could be Channel or GuildChannel
|
||||||
* @typedef {string} ChannelType
|
* @typedef {string} ChannelType
|
||||||
* @see {@link https://discord.com/developers/docs/resources/channel#channel-object-channel-types}
|
* @see {@link https://discord.com/developers/docs/resources/channel#channel-object-channel-types}
|
||||||
@@ -547,6 +548,7 @@ exports.ChannelTypes = createEnum([
|
|||||||
'GUILD_PUBLIC_THREAD',
|
'GUILD_PUBLIC_THREAD',
|
||||||
'GUILD_PRIVATE_THREAD',
|
'GUILD_PRIVATE_THREAD',
|
||||||
'GUILD_STAGE_VOICE',
|
'GUILD_STAGE_VOICE',
|
||||||
|
'GUILD_DIRECTORY',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
1
typings/enums.d.ts
vendored
1
typings/enums.d.ts
vendored
@@ -48,6 +48,7 @@ export const enum ChannelTypes {
|
|||||||
GUILD_PUBLIC_THREAD = 11,
|
GUILD_PUBLIC_THREAD = 11,
|
||||||
GUILD_PRIVATE_THREAD = 12,
|
GUILD_PRIVATE_THREAD = 12,
|
||||||
GUILD_STAGE_VOICE = 13,
|
GUILD_STAGE_VOICE = 13,
|
||||||
|
GUILD_DIRECTORY = 14,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const enum MessageTypes {
|
export const enum MessageTypes {
|
||||||
|
|||||||
4
typings/index.d.ts
vendored
4
typings/index.d.ts
vendored
@@ -523,6 +523,7 @@ export type CategoryChannelTypes = ExcludeEnum<
|
|||||||
| 'GUILD_NEWS_THREAD'
|
| 'GUILD_NEWS_THREAD'
|
||||||
| 'GUILD_PRIVATE_THREAD'
|
| 'GUILD_PRIVATE_THREAD'
|
||||||
| 'GUILD_CATEGORY'
|
| 'GUILD_CATEGORY'
|
||||||
|
| 'GUILD_DIRECTORY'
|
||||||
>;
|
>;
|
||||||
|
|
||||||
export class CategoryChannel extends GuildChannel {
|
export class CategoryChannel extends GuildChannel {
|
||||||
@@ -557,6 +558,7 @@ export abstract class Channel extends Base {
|
|||||||
public isText(): this is TextBasedChannel;
|
public isText(): this is TextBasedChannel;
|
||||||
public isVoice(): this is BaseGuildVoiceChannel;
|
public isVoice(): this is BaseGuildVoiceChannel;
|
||||||
public isThread(): this is ThreadChannel;
|
public isThread(): this is ThreadChannel;
|
||||||
|
public isDirectory(): this is DirectoryChannel;
|
||||||
public toString(): ChannelMention;
|
public toString(): ChannelMention;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2237,6 +2239,8 @@ export class StageChannel extends BaseGuildVoiceChannel {
|
|||||||
public setTopic(topic: string): Promise<StageChannel>;
|
public setTopic(topic: string): Promise<StageChannel>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class DirectoryChannel extends Channel {}
|
||||||
|
|
||||||
export class StageInstance extends Base {
|
export class StageInstance extends Base {
|
||||||
private constructor(client: Client, data: RawStageInstanceData, channel: StageChannel);
|
private constructor(client: Client, data: RawStageInstanceData, channel: StageChannel);
|
||||||
public id: Snowflake;
|
public id: Snowflake;
|
||||||
|
|||||||
Reference in New Issue
Block a user