K
Kord2y ago
rebok

Extract the thread id from a ThreadCreated message

How do i extract the thread id from a message of type MessageType.ThreadCreated?
18 Replies
g
g2y ago
You'd use the channel or channelId property
rebok
rebokOP2y ago
message.channel returns the channel message has been sent to and not the thread channel
g
g2y ago
Oh, I see what you mean Maybe it's in the data property somewhere?
rebok
rebokOP2y ago
no, nothing new, it doesn't seem to be in mentionedChannels and content only returns the thread name
g
g2y ago
Hmm, it has to be in there somewhere, but I can't go look myself right now
SchlaubiBus
SchlaubiBus2y ago
@LustigerLurch shouldn't MessageData have a thread field?
SchlaubiBus
SchlaubiBus2y ago
Discord Developer Portal
Discord Developer Portal — API Docs for Bots and Developers
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
SchlaubiBus
SchlaubiBus2y ago
Could you set the log level to TRACE and check whether the thread field is present for that message After looking into this you can't, you can only get the thread from the message which created the thread itself
rebok
rebokOP2y ago
I printed message.data and realized that the message id is basically the thread id
SchlaubiBus
SchlaubiBus2y ago
That's interesting
LustigerLurch
LustigerLurch2y ago
you're right, at least its id for caching
LustigerLurch
LustigerLurch2y ago
@rebok https://discord.com/developers/docs/topics/threads#new-message-types it seems to be message.messageReference?.channel?.id
Discord Developer Portal
Discord Developer Portal — API Docs for Bots and Developers
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
SchlaubiBus
SchlaubiBus2y ago
this will be available in my PR @LustigerLurch could you guess why it 401'd
LustigerLurch
LustigerLurch2y ago
maybe it is time for message subtypes that account for these strange cases @gdude ...
SchlaubiBus
SchlaubiBus2y ago
I mean this makes sense the thread created message is a reply to the creating message
LustigerLurch
LustigerLurch2y ago
what did 401? receiving the message can't be it
SchlaubiBus
SchlaubiBus2y ago
But yeah subtypes would probbably improve discoverability sonatype oh wait maybe it's the new account center
g
g2y ago
yeah subtypes might be good, that was part of bart's plan a long time ago anyway

Did you find this page helpful?