refactor: replace usage of deprecated ChannelTypes (#8625)

refactor: use new non-deprecated `ChannelType`s

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Almeida
2022-09-17 14:56:19 +01:00
committed by GitHub
parent 678ceaa014
commit 669c3cd256
12 changed files with 68 additions and 75 deletions

View File

@@ -234,7 +234,7 @@ describe('Slash Commands', () => {
expect(() => { expect(() => {
getBuilder().addChannelOption( getBuilder().addChannelOption(
getChannelOption().addChannelTypes(ChannelType.GuildNews, ChannelType.GuildText), getChannelOption().addChannelTypes(ChannelType.GuildAnnouncement, ChannelType.GuildText),
); );
}).not.toThrowError(); }).not.toThrowError();
}); });

View File

@@ -6,10 +6,10 @@ const allowedChannelTypes = [
ChannelType.GuildText, ChannelType.GuildText,
ChannelType.GuildVoice, ChannelType.GuildVoice,
ChannelType.GuildCategory, ChannelType.GuildCategory,
ChannelType.GuildNews, ChannelType.GuildAnnouncement,
ChannelType.GuildNewsThread, ChannelType.AnnouncementThread,
ChannelType.GuildPublicThread, ChannelType.PublicThread,
ChannelType.GuildPrivateThread, ChannelType.PrivateThread,
ChannelType.GuildStageVoice, ChannelType.GuildStageVoice,
] as const; ] as const;

View File

@@ -65,13 +65,13 @@ class ThreadManager extends CachedManager {
* @typedef {StartThreadOptions} ThreadCreateOptions * @typedef {StartThreadOptions} ThreadCreateOptions
* @property {MessageResolvable} [startMessage] The message to start a thread from. <warn>If this is defined then type * @property {MessageResolvable} [startMessage] The message to start a thread from. <warn>If this is defined then type
* of thread gets automatically defined and cannot be changed. The provided `type` field will be ignored</warn> * of thread gets automatically defined and cannot be changed. The provided `type` field will be ignored</warn>
* @property {ChannelType.GuildNewsThread|ChannelType.GuildPublicThread|ChannelType.GuildPrivateThread} [type] * @property {ChannelType.AnnouncementThread|ChannelType.PublicThread|ChannelType.PrivateThread} [type]
* The type of thread to create. * The type of thread to create.
* Defaults to {@link ChannelType.GuildPublicThread} if created in a {@link TextChannel} * Defaults to {@link ChannelType.PublicThread} if created in a {@link TextChannel}
* <warn>When creating threads in a {@link NewsChannel} this is ignored and is always * <warn>When creating threads in a {@link NewsChannel} this is ignored and is always
* {@link ChannelType.GuildNewsThread}</warn> * {@link ChannelType.AnnouncementThread}</warn>
* @property {boolean} [invitable] Whether non-moderators can add other non-moderators to the thread * @property {boolean} [invitable] Whether non-moderators can add other non-moderators to the thread
* <info>Can only be set when type will be {@link ChannelType.GuildPrivateThread}</info> * <info>Can only be set when type will be {@link ChannelType.PrivateThread}</info>
*/ */
/** /**
@@ -94,7 +94,7 @@ class ThreadManager extends CachedManager {
* .create({ * .create({
* name: 'mod-talk', * name: 'mod-talk',
* autoArchiveDuration: ThreadAutoArchiveDuration.OneHour, * autoArchiveDuration: ThreadAutoArchiveDuration.OneHour,
* type: ChannelType.GuildPrivateThread, * type: ChannelType.PrivateThread,
* reason: 'Needed a separate thread for moderation', * reason: 'Needed a separate thread for moderation',
* }) * })
* .then(threadChannel => console.log(threadChannel)) * .then(threadChannel => console.log(threadChannel))
@@ -113,12 +113,12 @@ class ThreadManager extends CachedManager {
throw new TypeError(ErrorCodes.InvalidType, 'type', 'ThreadChannelType or Number'); throw new TypeError(ErrorCodes.InvalidType, 'type', 'ThreadChannelType or Number');
} }
let resolvedType = let resolvedType =
this.channel.type === ChannelType.GuildNews ? ChannelType.GuildNewsThread : ChannelType.GuildPublicThread; this.channel.type === ChannelType.GuildAnnouncement ? ChannelType.AnnouncementThread : ChannelType.PublicThread;
let startMessageId; let startMessageId;
if (startMessage) { if (startMessage) {
startMessageId = this.channel.messages.resolveId(startMessage); startMessageId = this.channel.messages.resolveId(startMessage);
if (!startMessageId) throw new TypeError(ErrorCodes.InvalidType, 'startMessage', 'MessageResolvable'); if (!startMessageId) throw new TypeError(ErrorCodes.InvalidType, 'startMessage', 'MessageResolvable');
} else if (this.channel.type !== ChannelType.GuildNews) { } else if (this.channel.type !== ChannelType.GuildAnnouncement) {
resolvedType = type ?? resolvedType; resolvedType = type ?? resolvedType;
} }
@@ -127,7 +127,7 @@ class ThreadManager extends CachedManager {
name, name,
auto_archive_duration: autoArchiveDuration, auto_archive_duration: autoArchiveDuration,
type: resolvedType, type: resolvedType,
invitable: resolvedType === ChannelType.GuildPrivateThread ? invitable : undefined, invitable: resolvedType === ChannelType.PrivateThread ? invitable : undefined,
rate_limit_per_user: rateLimitPerUser, rate_limit_per_user: rateLimitPerUser,
}, },
reason, reason,

View File

@@ -92,7 +92,7 @@ class BaseGuildTextChannel extends GuildChannel {
/** /**
* Sets the type of this channel. * Sets the type of this channel.
* <info>Only conversion between {@link TextChannel} and {@link NewsChannel} is supported.</info> * <info>Only conversion between {@link TextChannel} and {@link NewsChannel} is supported.</info>
* @param {ChannelType.GuildText|ChannelType.GuildNews} type The new channel type * @param {ChannelType.GuildText|ChannelType.GuildAnnouncement} type The new channel type
* @param {string} [reason] Reason for changing the channel's type * @param {string} [reason] Reason for changing the channel's type
* @returns {Promise<GuildChannel>} * @returns {Promise<GuildChannel>}
*/ */

View File

@@ -1277,7 +1277,7 @@ class Guild extends AnonymousGuild {
*/ */
_sortedChannels(channel) { _sortedChannels(channel) {
const category = channel.type === ChannelType.GuildCategory; const category = channel.type === ChannelType.GuildCategory;
const channelTypes = [ChannelType.GuildText, ChannelType.GuildNews]; const channelTypes = [ChannelType.GuildText, ChannelType.GuildAnnouncement];
return discordSort( return discordSort(
this.channels.cache.filter( this.channels.cache.filter(
c => c =>

View File

@@ -636,7 +636,7 @@ class Message extends Base {
(this.author.id === this.client.user.id ? PermissionsBitField.DefaultBit : PermissionFlagsBits.ManageMessages); (this.author.id === this.client.user.id ? PermissionsBitField.DefaultBit : PermissionFlagsBits.ManageMessages);
const { channel } = this; const { channel } = this;
return Boolean( return Boolean(
channel?.type === ChannelType.GuildNews && channel?.type === ChannelType.GuildAnnouncement &&
!this.flags.has(MessageFlags.Crossposted) && !this.flags.has(MessageFlags.Crossposted) &&
this.type === MessageType.Default && this.type === MessageType.Default &&
channel.viewable && channel.viewable &&
@@ -664,7 +664,7 @@ class Message extends Base {
* @returns {Promise<Message>} * @returns {Promise<Message>}
* @example * @example
* // Crosspost a message * // Crosspost a message
* if (message.channel.type === ChannelType.GuildNews) { * if (message.channel.type === ChannelType.GuildAnnouncement) {
* message.crosspost() * message.crosspost()
* .then(() => console.log('Crossposted message')) * .then(() => console.log('Crossposted message'))
* .catch(console.error); * .catch(console.error);
@@ -806,7 +806,7 @@ class Message extends Base {
*/ */
startThread(options = {}) { startThread(options = {}) {
if (!this.channel) return Promise.reject(new Error(ErrorCodes.ChannelNotCached)); if (!this.channel) return Promise.reject(new Error(ErrorCodes.ChannelNotCached));
if (![ChannelType.GuildText, ChannelType.GuildNews].includes(this.channel.type)) { if (![ChannelType.GuildText, ChannelType.GuildAnnouncement].includes(this.channel.type)) {
return Promise.reject(new Error(ErrorCodes.MessageThreadParent)); return Promise.reject(new Error(ErrorCodes.MessageThreadParent));
} }
if (this.hasThread) return Promise.reject(new Error(ErrorCodes.MessageExistingThread)); if (this.hasThread) return Promise.reject(new Error(ErrorCodes.MessageExistingThread));

View File

@@ -15,7 +15,7 @@ class NewsChannel extends BaseGuildTextChannel {
* @param {string} [reason] Reason for creating the webhook * @param {string} [reason] Reason for creating the webhook
* @returns {Promise<NewsChannel>} * @returns {Promise<NewsChannel>}
* @example * @example
* if (channel.type === ChannelType.GuildNews) { * if (channel.type === ChannelType.GuildAnnouncement) {
* channel.addFollower('222197033908436994', 'Important announcements') * channel.addFollower('222197033908436994', 'Important announcements')
* .then(() => console.log('Added follower')) * .then(() => console.log('Added follower'))
* .catch(console.error); * .catch(console.error);

View File

@@ -80,7 +80,7 @@ class ThreadChannel extends BaseChannel {
* <info>This property is always `null` in public threads.</info> * <info>This property is always `null` in public threads.</info>
* @type {?boolean} * @type {?boolean}
*/ */
this.invitable = this.type === ChannelType.GuildPrivateThread ? data.thread_metadata.invitable ?? false : null; this.invitable = this.type === ChannelType.PrivateThread ? data.thread_metadata.invitable ?? false : null;
/** /**
* Whether the thread is archived * Whether the thread is archived
@@ -114,7 +114,7 @@ class ThreadChannel extends BaseChannel {
this.invitable ??= null; this.invitable ??= null;
} }
this._createdTimestamp ??= this.type === ChannelType.GuildPrivateThread ? super.createdTimestamp : null; this._createdTimestamp ??= this.type === ChannelType.PrivateThread ? super.createdTimestamp : null;
if ('owner_id' in data) { if ('owner_id' in data) {
/** /**
@@ -301,7 +301,7 @@ class ThreadChannel extends BaseChannel {
* @property {boolean} [locked] Whether the thread is locked * @property {boolean} [locked] Whether the thread is locked
* @property {boolean} [invitable] Whether non-moderators can add other non-moderators to a thread * @property {boolean} [invitable] Whether non-moderators can add other non-moderators to a thread
* @property {string} [reason] Reason for editing the thread * @property {string} [reason] Reason for editing the thread
* <info>Can only be edited on {@link ChannelType.GuildPrivateThread}</info> * <info>Can only be edited on {@link ChannelType.PrivateThread}</info>
*/ */
/** /**
@@ -322,7 +322,7 @@ class ThreadChannel extends BaseChannel {
auto_archive_duration: data.autoArchiveDuration, auto_archive_duration: data.autoArchiveDuration,
rate_limit_per_user: data.rateLimitPerUser, rate_limit_per_user: data.rateLimitPerUser,
locked: data.locked, locked: data.locked,
invitable: this.type === ChannelType.GuildPrivateThread ? data.invitable : undefined, invitable: this.type === ChannelType.PrivateThread ? data.invitable : undefined,
}, },
reason: data.reason, reason: data.reason,
}); });
@@ -371,7 +371,7 @@ class ThreadChannel extends BaseChannel {
* @returns {Promise<ThreadChannel>} * @returns {Promise<ThreadChannel>}
*/ */
setInvitable(invitable = true, reason) { setInvitable(invitable = true, reason) {
if (this.type !== ChannelType.GuildPrivateThread) { if (this.type !== ChannelType.PrivateThread) {
return Promise.reject(new RangeError(ErrorCodes.ThreadInvitableType, this.type)); return Promise.reject(new RangeError(ErrorCodes.ThreadInvitableType, this.type));
} }
return this.edit({ invitable, reason }); return this.edit({ invitable, reason });
@@ -435,7 +435,7 @@ class ThreadChannel extends BaseChannel {
*/ */
get editable() { get editable() {
return ( return (
(this.ownerId === this.client.user.id && (this.type !== ChannelType.GuildPrivateThread || this.joined)) || (this.ownerId === this.client.user.id && (this.type !== ChannelType.PrivateThread || this.joined)) ||
this.manageable this.manageable
); );
} }
@@ -450,9 +450,7 @@ class ThreadChannel extends BaseChannel {
!this.archived && !this.archived &&
!this.joined && !this.joined &&
this.permissionsFor(this.client.user)?.has( this.permissionsFor(this.client.user)?.has(
this.type === ChannelType.GuildPrivateThread this.type === ChannelType.PrivateThread ? PermissionFlagsBits.ManageThreads : PermissionFlagsBits.ViewChannel,
? PermissionFlagsBits.ManageThreads
: PermissionFlagsBits.ViewChannel,
false, false,
) )
); );
@@ -500,7 +498,7 @@ class ThreadChannel extends BaseChannel {
return ( return (
!(this.archived && this.locked && !this.manageable) && !(this.archived && this.locked && !this.manageable) &&
(this.type !== ChannelType.GuildPrivateThread || this.joined || this.manageable) && (this.type !== ChannelType.PrivateThread || this.joined || this.manageable) &&
permissions.has(PermissionFlagsBits.SendMessagesInThreads, false) && permissions.has(PermissionFlagsBits.SendMessagesInThreads, false) &&
this.guild.members.me.communicationDisabledUntilTimestamp < Date.now() this.guild.members.me.communicationDisabledUntilTimestamp < Date.now()
); );

View File

@@ -47,7 +47,7 @@ function createChannel(client, data, guild, { allowUnknownGuild, fromInteraction
channel = new (getCategoryChannel())(guild, data, client); channel = new (getCategoryChannel())(guild, data, client);
break; break;
} }
case ChannelType.GuildNews: { case ChannelType.GuildAnnouncement: {
channel = new (getNewsChannel())(guild, data, client); channel = new (getNewsChannel())(guild, data, client);
break; break;
} }
@@ -55,9 +55,9 @@ function createChannel(client, data, guild, { allowUnknownGuild, fromInteraction
channel = new (getStageChannel())(guild, data, client); channel = new (getStageChannel())(guild, data, client);
break; break;
} }
case ChannelType.GuildNewsThread: case ChannelType.AnnouncementThread:
case ChannelType.GuildPublicThread: case ChannelType.PublicThread:
case ChannelType.GuildPrivateThread: { case ChannelType.PrivateThread: {
channel = new (getThreadChannel())(guild, data, client, fromInteraction); channel = new (getThreadChannel())(guild, data, client, fromInteraction);
if (!allowUnknownGuild) channel.parent?.threads.cache.set(channel.id, channel); if (!allowUnknownGuild) channel.parent?.threads.cache.set(channel.id, channel);
break; break;

View File

@@ -79,35 +79,31 @@ exports.NonSystemMessageTypes = [
* The types of channels that are text-based. The available types are: * The types of channels that are text-based. The available types are:
* * {@link ChannelType.DM} * * {@link ChannelType.DM}
* * {@link ChannelType.GuildText} * * {@link ChannelType.GuildText}
* * {@link ChannelType.GuildNews} * * {@link ChannelType.GuildAnnouncement}
* * {@link ChannelType.GuildNewsThread} * * {@link ChannelType.AnnouncementThread}
* * {@link ChannelType.GuildPublicThread} * * {@link ChannelType.PublicThread}
* * {@link ChannelType.GuildPrivateThread} * * {@link ChannelType.PrivateThread}
* * {@link ChannelType.GuildVoice} * * {@link ChannelType.GuildVoice}
* @typedef {ChannelType[]} TextBasedChannelTypes * @typedef {ChannelType[]} TextBasedChannelTypes
*/ */
exports.TextBasedChannelTypes = [ exports.TextBasedChannelTypes = [
ChannelType.DM, ChannelType.DM,
ChannelType.GuildText, ChannelType.GuildText,
ChannelType.GuildNews, ChannelType.GuildAnnouncement,
ChannelType.GuildNewsThread, ChannelType.AnnouncementThread,
ChannelType.GuildPublicThread, ChannelType.PublicThread,
ChannelType.GuildPrivateThread, ChannelType.PrivateThread,
ChannelType.GuildVoice, ChannelType.GuildVoice,
]; ];
/** /**
* The types of channels that are threads. The available types are: * The types of channels that are threads. The available types are:
* * {@link ChannelType.GuildNewsThread} * * {@link ChannelType.AnnouncementThread}
* * {@link ChannelType.GuildPublicThread} * * {@link ChannelType.PublicThread}
* * {@link ChannelType.GuildPrivateThread} * * {@link ChannelType.PrivateThread}
* @typedef {ChannelType[]} ThreadChannelTypes * @typedef {ChannelType[]} ThreadChannelTypes
*/ */
exports.ThreadChannelTypes = [ exports.ThreadChannelTypes = [ChannelType.AnnouncementThread, ChannelType.PublicThread, ChannelType.PrivateThread];
ChannelType.GuildNewsThread,
ChannelType.GuildPublicThread,
ChannelType.GuildPrivateThread,
];
/** /**
* The types of channels that are voice-based. The available types are: * The types of channels that are voice-based. The available types are:

View File

@@ -517,7 +517,7 @@ export class BaseGuildTextChannel extends TextBasedChannelMixin(GuildChannel, tr
): Promise<this>; ): Promise<this>;
public setTopic(topic: string | null, reason?: string): Promise<this>; public setTopic(topic: string | null, reason?: string): Promise<this>;
public setType(type: ChannelType.GuildText, reason?: string): Promise<TextChannel>; public setType(type: ChannelType.GuildText, reason?: string): Promise<TextChannel>;
public setType(type: ChannelType.GuildNews, reason?: string): Promise<NewsChannel>; public setType(type: ChannelType.GuildAnnouncement, reason?: string): Promise<NewsChannel>;
} }
export class BaseGuildVoiceChannel extends GuildChannel { export class BaseGuildVoiceChannel extends GuildChannel {
@@ -701,7 +701,7 @@ export class Embed {
} }
export interface MappedChannelCategoryTypes { export interface MappedChannelCategoryTypes {
[ChannelType.GuildNews]: NewsChannel; [ChannelType.GuildAnnouncement]: NewsChannel;
[ChannelType.GuildVoice]: VoiceChannel; [ChannelType.GuildVoice]: VoiceChannel;
[ChannelType.GuildText]: TextChannel; [ChannelType.GuildText]: TextChannel;
[ChannelType.GuildStageVoice]: StageChannel; [ChannelType.GuildStageVoice]: StageChannel;
@@ -712,9 +712,9 @@ export type CategoryChannelType = Exclude<
ChannelType, ChannelType,
| ChannelType.DM | ChannelType.DM
| ChannelType.GroupDM | ChannelType.GroupDM
| ChannelType.GuildPublicThread | ChannelType.PublicThread
| ChannelType.GuildNewsThread | ChannelType.AnnouncementThread
| ChannelType.GuildPrivateThread | ChannelType.PrivateThread
| ChannelType.GuildCategory | ChannelType.GuildCategory
| ChannelType.GuildDirectory | ChannelType.GuildDirectory
>; >;
@@ -2019,7 +2019,7 @@ export class ModalSubmitInteraction<Cached extends CacheType = CacheType> extend
export class NewsChannel extends BaseGuildTextChannel { export class NewsChannel extends BaseGuildTextChannel {
public threads: ThreadManager<AllowedThreadTypeForNewsChannel>; public threads: ThreadManager<AllowedThreadTypeForNewsChannel>;
public type: ChannelType.GuildNews; public type: ChannelType.GuildAnnouncement;
public addFollower(channel: TextChannelResolvable, reason?: string): Promise<NewsChannel>; public addFollower(channel: TextChannelResolvable, reason?: string): Promise<NewsChannel>;
} }
@@ -2496,13 +2496,13 @@ export class TextChannel extends BaseGuildTextChannel {
export type AnyThreadChannel = PublicThreadChannel | PrivateThreadChannel; export type AnyThreadChannel = PublicThreadChannel | PrivateThreadChannel;
export interface PublicThreadChannel extends ThreadChannel { export interface PublicThreadChannel extends ThreadChannel {
type: ChannelType.GuildPublicThread | ChannelType.GuildNewsThread; type: ChannelType.PublicThread | ChannelType.AnnouncementThread;
} }
export interface PrivateThreadChannel extends ThreadChannel { export interface PrivateThreadChannel extends ThreadChannel {
get createdTimestamp(): number; get createdTimestamp(): number;
get createdAt(): Date; get createdAt(): Date;
type: ChannelType.GuildPrivateThread; type: ChannelType.PrivateThread;
} }
export class ThreadChannel extends TextBasedChannelMixin(BaseChannel, true, [ export class ThreadChannel extends TextBasedChannelMixin(BaseChannel, true, [
@@ -3759,9 +3759,9 @@ export interface AddGuildMemberOptions {
export type AllowedPartial = User | Channel | GuildMember | Message | MessageReaction | ThreadMember; export type AllowedPartial = User | Channel | GuildMember | Message | MessageReaction | ThreadMember;
export type AllowedThreadTypeForNewsChannel = ChannelType.GuildNewsThread; export type AllowedThreadTypeForNewsChannel = ChannelType.AnnouncementThread;
export type AllowedThreadTypeForTextChannel = ChannelType.GuildPublicThread | ChannelType.GuildPrivateThread; export type AllowedThreadTypeForTextChannel = ChannelType.PublicThread | ChannelType.PrivateThread;
export interface BaseApplicationCommandData { export interface BaseApplicationCommandData {
name: string; name: string;
@@ -4810,9 +4810,9 @@ export interface GuildChannelCreateOptions extends Omit<CategoryCreateChannelOpt
ChannelType, ChannelType,
| ChannelType.DM | ChannelType.DM
| ChannelType.GroupDM | ChannelType.GroupDM
| ChannelType.GuildPublicThread | ChannelType.PublicThread
| ChannelType.GuildNewsThread | ChannelType.AnnouncementThread
| ChannelType.GuildPrivateThread | ChannelType.PrivateThread
>; >;
} }
@@ -4822,7 +4822,7 @@ export interface GuildChannelCloneOptions extends Omit<GuildChannelCreateOptions
export interface GuildChannelEditOptions { export interface GuildChannelEditOptions {
name?: string; name?: string;
type?: ChannelType.GuildText | ChannelType.GuildNews; type?: ChannelType.GuildText | ChannelType.GuildAnnouncement;
position?: number; position?: number;
topic?: string | null; topic?: string | null;
nsfw?: boolean; nsfw?: boolean;
@@ -5560,15 +5560,12 @@ export type TextBasedChannelResolvable = Snowflake | TextBasedChannel;
export type ThreadChannelResolvable = AnyThreadChannel | Snowflake; export type ThreadChannelResolvable = AnyThreadChannel | Snowflake;
export type ThreadChannelType = export type ThreadChannelType = ChannelType.AnnouncementThread | ChannelType.PublicThread | ChannelType.PrivateThread;
| ChannelType.GuildNewsThread
| ChannelType.GuildPublicThread
| ChannelType.GuildPrivateThread;
export interface ThreadCreateOptions<AllowedThreadType> extends StartThreadOptions { export interface ThreadCreateOptions<AllowedThreadType> extends StartThreadOptions {
startMessage?: MessageResolvable; startMessage?: MessageResolvable;
type?: AllowedThreadType; type?: AllowedThreadType;
invitable?: AllowedThreadType extends ChannelType.GuildPrivateThread ? boolean : never; invitable?: AllowedThreadType extends ChannelType.PrivateThread ? boolean : never;
} }
export interface ThreadEditData { export interface ThreadEditData {

View File

@@ -1042,7 +1042,7 @@ client.on('stickerUpdate', ({ client: oldClient }, { client: newClient }) => {
client.on('threadCreate', thread => { client.on('threadCreate', thread => {
expectType<Client<true>>(thread.client); expectType<Client<true>>(thread.client);
if (thread.type === ChannelType.GuildPrivateThread) { if (thread.type === ChannelType.PrivateThread) {
expectType<number>(thread.createdTimestamp); expectType<number>(thread.createdTimestamp);
expectType<Date>(thread.createdAt); expectType<Date>(thread.createdAt);
} else { } else {
@@ -1238,7 +1238,7 @@ expectType<TextBasedChannelFields<true>['send']>(voiceChannel.send);
expectAssignable<PartialTextBasedChannelFields>(user); expectAssignable<PartialTextBasedChannelFields>(user);
expectAssignable<PartialTextBasedChannelFields>(guildMember); expectAssignable<PartialTextBasedChannelFields>(guildMember);
expectType<Promise<NewsChannel>>(textChannel.setType(ChannelType.GuildNews)); expectType<Promise<NewsChannel>>(textChannel.setType(ChannelType.GuildAnnouncement));
expectType<Promise<TextChannel>>(newsChannel.setType(ChannelType.GuildText)); expectType<Promise<TextChannel>>(newsChannel.setType(ChannelType.GuildText));
expectType<Message | null>(dmChannel.lastMessage); expectType<Message | null>(dmChannel.lastMessage);
@@ -1348,7 +1348,9 @@ declare const categoryChannelChildManager: CategoryChannelChildManager;
{ {
expectType<Promise<VoiceChannel>>(categoryChannelChildManager.create({ name: 'name', type: ChannelType.GuildVoice })); expectType<Promise<VoiceChannel>>(categoryChannelChildManager.create({ name: 'name', type: ChannelType.GuildVoice }));
expectType<Promise<TextChannel>>(categoryChannelChildManager.create({ name: 'name', type: ChannelType.GuildText })); expectType<Promise<TextChannel>>(categoryChannelChildManager.create({ name: 'name', type: ChannelType.GuildText }));
expectType<Promise<NewsChannel>>(categoryChannelChildManager.create({ name: 'name', type: ChannelType.GuildNews })); expectType<Promise<NewsChannel>>(
categoryChannelChildManager.create({ name: 'name', type: ChannelType.GuildAnnouncement }),
);
expectType<Promise<StageChannel>>( expectType<Promise<StageChannel>>(
categoryChannelChildManager.create({ name: 'name', type: ChannelType.GuildStageVoice }), categoryChannelChildManager.create({ name: 'name', type: ChannelType.GuildStageVoice }),
); );
@@ -1365,7 +1367,7 @@ declare const guildChannelManager: GuildChannelManager;
expectType<Promise<VoiceChannel>>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildVoice })); expectType<Promise<VoiceChannel>>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildVoice }));
expectType<Promise<CategoryChannel>>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildCategory })); expectType<Promise<CategoryChannel>>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildCategory }));
expectType<Promise<TextChannel>>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildText })); expectType<Promise<TextChannel>>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildText }));
expectType<Promise<NewsChannel>>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildNews })); expectType<Promise<NewsChannel>>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildAnnouncement }));
expectType<Promise<StageChannel>>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildStageVoice })); expectType<Promise<StageChannel>>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildStageVoice }));
expectType<Promise<Collection<Snowflake, AnyChannel | null>>>(guildChannelManager.fetch()); expectType<Promise<Collection<Snowflake, AnyChannel | null>>>(guildChannelManager.fetch());
@@ -1839,9 +1841,9 @@ declare const NonThreadGuildBasedChannel: NonThreadGuildBasedChannel;
declare const GuildTextBasedChannel: GuildTextBasedChannel; declare const GuildTextBasedChannel: GuildTextBasedChannel;
expectType<TextBasedChannel>(TextBasedChannel); expectType<TextBasedChannel>(TextBasedChannel);
expectType<ChannelType.GuildText | ChannelType.DM | ChannelType.GuildNews | ChannelType.GuildVoice | ThreadChannelType>( expectType<
TextBasedChannelTypes, ChannelType.GuildText | ChannelType.DM | ChannelType.GuildAnnouncement | ChannelType.GuildVoice | ThreadChannelType
); >(TextBasedChannelTypes);
expectType<StageChannel | VoiceChannel>(VoiceBasedChannel); expectType<StageChannel | VoiceChannel>(VoiceBasedChannel);
expectType<GuildBasedChannel>(GuildBasedChannel); expectType<GuildBasedChannel>(GuildBasedChannel);
expectType<CategoryChannel | NewsChannel | StageChannel | TextChannel | VoiceChannel>(NonThreadGuildBasedChannel); expectType<CategoryChannel | NewsChannel | StageChannel | TextChannel | VoiceChannel>(NonThreadGuildBasedChannel);