@sapphire/discord.js-utilities - isPrivateThreadChannel

Could I query about the return type from the isPrivateThreadChannel. Shouldn't that type-guard instead of being ThreadChannel be PrivateThreadChannel
import { container } from '@sapphire/framework'
import type { PrivateThreadChannel, Snowflake } from 'discord.js'
import { ChannelType } from 'discord.js'

/**
* Attempts to fetch a {@link PrivateThreadChannel} from the provided channelId
*/
export async function getPrivateThreadChannel(channelId: Snowflake): Promise<PrivateThreadChannel> {
const channel = await container.client.channels.fetch(channelId)
if (channel?.type === ChannelType.PrivateThread) {
return channel
}
throw new Error('channelId is not a Private Thread Channel')
}
import { container } from '@sapphire/framework'
import type { PrivateThreadChannel, Snowflake } from 'discord.js'
import { ChannelType } from 'discord.js'

/**
* Attempts to fetch a {@link PrivateThreadChannel} from the provided channelId
*/
export async function getPrivateThreadChannel(channelId: Snowflake): Promise<PrivateThreadChannel> {
const channel = await container.client.channels.fetch(channelId)
if (channel?.type === ChannelType.PrivateThread) {
return channel
}
throw new Error('channelId is not a Private Thread Channel')
}
The function above types the channel differently compared to isPrivateThreadChannel, is this intentional?
6 Replies
Favna
Favna16mo ago
you're right. Can you make a PR fixing this and the other type guards? They also use the deprecated enum members still
bazlow
bazlowOP16mo ago
Sure, i'll try and make a PR for this today then 👍
Favna
Favna16mo ago
any chance you'll have tim in the coming 2,5 hours or so? I want to do a release of packages then - after my daily grind in mmo
bazlow
bazlowOP16mo ago
I think so, this just involves some small changes, right?
Favna
Favna16mo ago
ye
Favna
Favna16mo ago
Released, see #Announcements
Want results from more Discord servers?
Add your server