#channel.send() is not a function

37 messages Ā· Page 1 of 1 (latest)

stark scaffold
#

Why is it randomly saying this is not a function. It was working an hour ago 😐

bronze falcon
#

what is channel?

mighty tartan
#

would need to see the rest of that line

stark scaffold
#

(ModMail system)

bronze falcon
#

can u show rest of line?

stark scaffold
#

Just .then()

bronze falcon
#

monbreyFacepalm what is before then

stark scaffold
mighty tartan
#

nah thats enough to say why this is wrong

stark scaffold
#

Like I said, it worked earlier today

mighty tartan
#

By chaining a second .then what you get is the return value of the first .then

#

Which is a message, not a channel

stark scaffold
#

so how would I fix this

bronze falcon
#

return chanel in first then

mighty tartan
#

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

stark scaffold
#

I moved the final .then

#

to a better place

#

but how do I fix the other thing

stark scaffold
bronze falcon
#

just use await

stark scaffold
#

What would that do to return it

somber thistleBOT
mighty tartan
#

I said how

mighty tartan
#

It returns a message so treat it like a message

stark scaffold
#

Putting them in a single .then does this

bronze falcon
stark scaffold
#

Yes