K
Kord6mo 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
gdude6mo ago
You'd use the channel or channelId property
rebok
rebok6mo ago
message.channel returns the channel message has been sent to and not the thread channel
gdude
gdude6mo ago
Oh, I see what you mean Maybe it's in the data property somewhere?
rebok
rebok6mo ago
no, nothing new, it doesn't seem to be in mentionedChannels and content only returns the thread name
gdude
gdude6mo ago
Hmm, it has to be in there somewhere, but I can't go look myself right now
SchlaubiBus
SchlaubiBus6mo ago
@LustigerLurch shouldn't MessageData have a thread field?
SchlaubiBus
SchlaubiBus6mo 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
SchlaubiBus6mo 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
rebok6mo ago
I printed message.data and realized that the message id is basically the thread id
SchlaubiBus
SchlaubiBus6mo ago
That's interesting
LustigerLurch
LustigerLurch6mo ago
you're right, at least its id for caching
LustigerLurch
LustigerLurch6mo 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
SchlaubiBus6mo ago
this will be available in my PR @LustigerLurch could you guess why it 401'd
LustigerLurch
LustigerLurch6mo ago
maybe it is time for message subtypes that account for these strange cases @gdude ...
SchlaubiBus
SchlaubiBus6mo ago
I mean this makes sense the thread created message is a reply to the creating message
Want results from more Discord servers?
Add your server