Hey there, first of all, thanks for the great project! It's awesome and really helpful :)
The issue I'm having is this: I'm sending bot responses passing an object and not a simple string, and when I do this, I get this error: ERROR TypeError: Cannot read property 'catch' of undefined at client.coffee:180:7 (see attachments for complete info) and the response is successfully sent.
When I send responses as plain strings, no errors are thrown.
Since I'm reviving an old project that was built using outdated versions of several packages and I updated them all, I'm not sure if this is a deprecated way of passing the bot's response. Also, I've read a few somehow-related issues, like issue 256 but it didn't help much, so any help would be appreciated!
Thanks in advance :)
hubot-slack version: 4.5.5
node version: 8.9.4
OS version(s): Ubuntu 18.04.1
Messages being sent without showing any errors.
Messages are sent, but errors are thrown.
Here's how I call the response.send:
response.send(
{
room: response.message.user.room
},
{
as_user: true,
attachments: [
{
title: "Information",
text: message,
color: "#1e90ff",
mrkdwn_in: ["text"]
}
]
},
() => resolve() //I'm using promises
);
And that's the error stack I get:
[Wed Nov 28 2018 15:05:52 GMT+0000 (UTC)] ERROR TypeError: Cannot read property 'catch' of undefined
at SlackClient.send (/home/node/app/node_modules/hubot-slack/src/client.coffee:180:7, <js>:186:91)
at SlackBot.send (/home/node/app/node_modules/hubot-slack/src/bot.coffee:86:7, <js>:104:37)
at runAdapterSend (/home/node/app/node_modules/hubot/src/response.js:116:38)
at allDone (/home/node/app/node_modules/hubot/src/middleware.js:56:7)
at /home/node/app/node_modules/async/lib/async.js:274:13
at Object.async.eachSeries (/home/node/app/node_modules/async/lib/async.js:142:20)
at async.reduce (/home/node/app/node_modules/async/lib/async.js:268:15)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickDomainCallback (internal/process/next_tick.js:218:9)
error: Response not OK: no_text
Hey @caio92 馃憢I see two problems here.
When you're calling response.send(), you don't actually need to include the envelope parameter yourself (which is { room: response.message.user.room } in your code). This is automatically added to the function call in bot.coffee. So you can just remove the first parameter you're passing.
Secondly, I'm not sure how you're using promises, but you shouldn't pass the resolve() into the send function. The function is interpreting that as another message you're trying to send.
I got it to work without errors with this call:
res.send(
{
as_user: true,
attachments: [
{
title: "Information",
text: message,
color: "#1e90ff",
mrkdwn_in: ["text"]
}
]
}
);
Hey @shanedewael, thanks a lot for the quick and precise response! I fixed the two problems you pointed out and it works like a charm now! :)
Most helpful comment
Hey @caio92 馃憢I see two problems here.
When you're calling
response.send(), you don't actually need to include the envelope parameter yourself (which is{ room: response.message.user.room }in your code). This is automatically added to the function call in bot.coffee. So you can just remove the first parameter you're passing.Secondly, I'm not sure how you're using promises, but you shouldn't pass the
resolve()into thesendfunction. The function is interpreting that as another message you're trying to send.I got it to work without errors with this call: