How i get the Threads property of the channel where slash commands were fired
Someone can help me?
I need a TextChannel to create a private thread, i'm trying to use the channel that interaction returns, but it returns a TextBasedChannel, where i can't to get the .Threads property.
What i need to use, to get the Textchannel where the interaction were fired
22 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
- ✅
Marked as resolved by OPYou'd want to use a combination of
-
interaction.inCachedGuild()
- !interaction.channel.isThread()
- !interaction.channel.isVoiceBased()
To ensure the channel is from a cached guild, isn't voice-based, and isn't a thread itself, which should then mean it's a NewsChannel or TextChannel with threadsIt still a TextBasedChannel
@TAEMBO.md
Because you missed the first typeguard I mentioned, and you also need to ensure it's not null
oh, my bad
but i can't get the
interaction.inCachedGuild()
, my interaction is a ChatInputCommandInteraction
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
:method: ChatInputCommandInteraction#inCachedGuild
@14.15.3
Indicates whether or not this interaction is both cached and received from a guild.i don't know if i doing right
I don't see where you're calling the
inCachedGuild()
method theremy bad again, i'm was writing wrong, lol 🤦♂️
but the channel still a TextBasedChannel
You're negating your
inCachedGuild()
call there with your !
before it, remove thatSame
Its weird, because it still a null
I would try restarting your TS server (or simply reopening your IDE), as I'm not able to reproduce this on my end
Well, hold on, what is
channel
there in your log
You're narrowing the types on interaction.channel
, but not on that channel
variable you have🤦♂️
I get a
GuildTextBasedChannel
nowRemove the optional chaining operators
?
before isThread()
and isVoiceBased()
, as you've already determined earlier that channel
isn't nullthat's worked
really thanks for the help and my bad for this mistakes, lol
❤️