channel.send() is not a function

Why is it randomly saying this is not a function. It was working an hour ago 😐
24 Replies
Jaworek
Jaworekβ€’3y ago
what is channel?
monbrey
monbreyβ€’3y ago
would need to see the rest of that line
π•―π–”π–‰π–”π•Ύπ–Šπ–†π–‘
Channel is a channel created by a command (ModMail system)
Jaworek
Jaworekβ€’3y ago
can u show rest of line?
Jaworek
Jaworekβ€’3y ago
monbreyFacepalm what is before then
monbrey
monbreyβ€’3y ago
nah thats enough to say why this is wrong
π•―π–”π–‰π–”π•Ύπ–Šπ–†π–‘
Like I said, it worked earlier today
monbrey
monbreyβ€’3y ago
By chaining a second .then what you get is the return value of the first .then Which is a message, not a channel
Jaworek
Jaworekβ€’3y ago
return chanel in first then
monbrey
monbreyβ€’3y ago
Dont shadow the channel variable, or just dont use multiple thens This is where async/await starts to become a much nicer syntax Your final third .then is wrong too Not a callback method You could do .then(message => message.channel.send in the middle one
π•―π–”π–‰π–”π•Ύπ–Šπ–†π–‘
I moved the final .then to a better place but how do I fix the other thing It wont let me
Jaworek
Jaworekβ€’3y ago
just use await
π•―π–”π–‰π–”π•Ύπ–Šπ–†π–‘
What would that do to return it
d.js docs
d.js docsβ€’3y ago
Resources to understand Promise: β€’ MDN: learn more β€’ Guide: learn more β€’ JavaScript info: learn more
monbrey
monbreyβ€’3y ago
I said how Literally this It returns a message so treat it like a message
π•―π–”π–‰π–”π•Ύπ–Šπ–†π–‘
Putting them in a single .then does this Ok
Jaworek
Jaworekβ€’3y ago
so its working
π•―π–”π–‰π–”π•Ύπ–Šπ–†π–‘
Yes Thanks for the help πŸ‘ I'm sorta new to this
Want results from more Discord servers?
Add your server