Message.channel type does not seem to have send and sendTyping in v14

My particular bot build is a typescipt build. The transpiler (and my edtior) indicate that the channel object in the Message type no longer has send and sendTyping. How are they meant to be used now? Is there a type to replace Message or something? I have tried to find any relevant info on this in the version to version migration guides and other posts here, but all I can figure out is the functions still seem to exist on the object and should work, but obviously typescript wont compile it if types dont allow it. My flow: - MessageCreate event callback calls messageHandler - message handler function has a parameter called message with type Message (imported from djs obviously) - handler does message.channel.sendTyping, does whatever data fetches for the message action and then message.channel.send the result node v22.3.0 djs 14.16.3
No description
11 Replies
d.js toolkit
d.js toolkit3mo ago
- 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!
Mark
Mark3mo ago
A) the Message class never had those methods, they're on channels B) use the isSendable guard to narrow the channel types
JMZ10
JMZ10OP3mo ago
I did mention it previously worked. So I'm not sure if we talking about the same Message class in terms of what it did or didnt have. I will lok into this sendle thing tho.
Mark
Mark3mo ago
I mean, your message suggests you're using message.channel.send and such, I just want to clarify that the channel is different than the message Because things like message.reply do exist to send a message as a reply
JMZ10
JMZ10OP3mo ago
Is that implying you cant send a message to the source channel of the Message event anymore?
Mark
Mark3mo ago
That's not what I said There is a difference between message.send (which doesn't exist) and message.channel.send (which does exist)
JMZ10
JMZ10OP3mo ago
My compile errors show im using the one that exists. Typescript says that one doesnt.
Mark
Mark3mo ago
That's why I told you to use the guard
Use the isSendable() type guard. Messages can originate from partial group DM channels because of user-installable applications and you can't send messages there, hence the need for the type guard
JMZ10
JMZ10OP3mo ago
the guard the a boolean function right? And somehow a boolean can resolve a variable type for ts to comple in this instance?
treble/luna
treble/luna3mo ago
its a typeguard it narrows the type
JMZ10
JMZ10OP3mo ago
Thanks. I got it working. Never done these before, legit thought it was a djs concept cause I dont do much advanced typescript techniues
Want results from more Discord servers?
Add your server