How can I consistently get the parent channel of a public thread?

DJS says thread.parent can be null. Reading issues and PRs (#8453, #8466), it seems like this occurs when a thread is created without a starting message in a channel. But it still belongs to a parent channel. So how can I get this parent channel?
23 Replies
d.js docs
d.js docs2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
MrMythical
MrMythical2y ago
if channel uncached
LeMorrow
LeMorrow2y ago
Hmmm I see, how would I fetch it? Since parentId is also nullable
LeMorrow
LeMorrow2y ago
LeMorrow
LeMorrow2y ago
no fetchParent in sight
d.js docs
d.js docs2y ago
class ThreadChannel (extends BaseChannel) Represents a thread channel on Discord.
LeMorrow
LeMorrow2y ago
I guess I could fetchStarterMessage and then fetch that channel ID
MrMythical
MrMythical2y ago
might be because partial, apparently could be in dm channels?
LeMorrow
LeMorrow2y ago
You can def not have threads in DMs lol Maybe group DMs? Nah checked that too
MrMythical
MrMythical2y ago
that's nice, misleading because .partial isn't overridden lol
LeMorrow
LeMorrow2y ago
I guess I can use that starterMessageId === parentChannelId and just fetch the parent that way Actually no, because people can delete the starter message So that doesn't work in some cases either
MrMythical
MrMythical2y ago
dapi docs also says nullable, not why tho
LeMorrow
LeMorrow2y ago
Weird, good to know it's not a DJS bug at least But I still need to figure out how to consistently fetch it lol
MrMythical
MrMythical2y ago
wait, no it's not a thread channel structure it shows for, it's for all Channel structures in dapi docs and it would be null if channel has no category
LeMorrow
LeMorrow2y ago
LeMorrow
LeMorrow2y ago
Doesn't mention it being null here: https://discord.com/developers/docs/topics/threads#threads TBH I don't know my way around DAPI docs
LeMorrow
LeMorrow2y ago
So thread inherits that from Channel?
MrMythical
MrMythical2y ago
yes so ig might be a small mistake with typings 🤷‍♂️
LeMorrow
LeMorrow2y ago
I'll open an issue and see what the response is, thank you for your help aha https://github.com/discordjs/discord.js/pull/8467 I could've sworn I saw something like this before but couldn't find it when I looked around This makes it seem intentional..
LeMorrow
LeMorrow2y ago
GitHub
ThreadChannel#fetchStartermessage throws sync error if parent is n...
Which package is this bug report for? discord.js Issue description Create thread (not on a message) Weep because you catch the promise rejection, but it still errors out discord.js/src/structures/T...
LeMorrow
LeMorrow2y ago
So it seems like this.parent is null if you create a thread that is not on a message... which is very weird because it still belongs to a channel Wonder if that's the API doing that Wait... I get it. There are public threads and private threads Private threads are basically like group DMs and don't belong to a channel Duh I was looking for PublicThreadChannel I'm still not sure exactly how I would get the parent from a PublicThreadChannel, so I'll leave the thread open because that would be good to know. But I'm not blocked by this anymore as what I really wanted was to know a GuildMember's permission in this thread, which now works with member.PermissionsIn(thread) Update: I now need to get the parentId of a PublicThreadChannel. It cannot be null. Any ideas? bump
GitHub
GitHub2y ago
<:issue_open:852714230280486942> #8471 in discordjs/discord.js by MarcusOtter opened <t:1660188726:R> parentId should never be null on PublicThreadChannel