K
Kord9mo 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
gdude
gdude9mo ago
You'd use the channel or channelId property
rebok
rebokOP9mo ago
message.channel returns the channel message has been sent to and not the thread channel
gdude
gdude9mo ago
Oh, I see what you mean Maybe it's in the data property somewhere?
rebok
rebokOP9mo ago
no, nothing new, it doesn't seem to be in mentionedChannels and content only returns the thread name
gdude
gdude9mo ago
Hmm, it has to be in there somewhere, but I can't go look myself right now
SchlaubiBus
SchlaubiBus9mo ago
@LustigerLurch shouldn't MessageData have a thread field?
SchlaubiBus
SchlaubiBus9mo 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
SchlaubiBus9mo 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
rebokOP9mo ago
I printed message.data and realized that the message id is basically the thread id
SchlaubiBus
SchlaubiBus9mo ago
That's interesting
LustigerLurch
LustigerLurch9mo ago
you're right, at least its id for caching
LustigerLurch
LustigerLurch9mo 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
SchlaubiBus9mo ago
this will be available in my PR @LustigerLurch could you guess why it 401'd
LustigerLurch
LustigerLurch9mo ago
maybe it is time for message subtypes that account for these strange cases @gdude ...
SchlaubiBus
SchlaubiBus9mo ago
I mean this makes sense the thread created message is a reply to the creating message
LustigerLurch
LustigerLurch9mo ago
what did 401? receiving the message can't be it
SchlaubiBus
SchlaubiBus9mo ago
But yeah subtypes would probbably improve discoverability sonatype oh wait maybe it's the new account center
gdude
gdude9mo ago
yeah subtypes might be good, that was part of bart's plan a long time ago anyway
Want results from more Discord servers?
Add your server