Node-slack-sdk: not able to call web api method "files.comments.delete" (or other comments methods)...

Created on 25 Jul 2016  Â·  4Comments  Â·  Source: slackapi/node-slack-sdk

looks like files.comments methods are not possible to call from web api wrapper?
I am sure that I pass the correct parameters, but the TypeError anyway indicates that files.comments methods are undefined?

/home/bot/bin/bot_a/index.js:313
web.files.comments.delete(message.file.id, message.comment.id, function ()
^
TypeError: Cannot call method 'delete' of undefined

Edit: This is the init procedure for my code - just for info:


var WebClient = require('@slack/client').WebClient;
var web = new WebClient(web_token);
[...snip...]
  if (message.subtype == 'file_comment') {
    console.log('file comment file id: ', message.file.id); // delivers correct ID from message
    console.log('file comment id: ', message.comment.id); // delivers correct ID from message
    web.files.comments.delete(message.file.id, message.comment.id, function () {}); // throws above error
    web.files.comments.add(message.file.id, 'TEST COMMENT...', function () {}); --> also not possible... same error...
  }
[...snip...]

This is different from any other web api methods I can call without issues, like web.files.delete a.s.o.
Do I miss something?
Thanks4help

bug

Most helpful comment

Ahaha, this is probably caused because the facet defines it's name as "files.comments" and the web client sets facets on itself with this[newFacet.name] = newFacet;. That means that what you want is actually web['files.comments'].delete currently.

I suspect this is just a bug and should be fixed in the future, though.


For possible fixes, maybe just set the field "comments" of the FilesFacet object, probably in it's constructor, to a FilesCommentsFacet object. Same for the usergroups.users facet!

All 4 comments

Ahaha, this is probably caused because the facet defines it's name as "files.comments" and the web client sets facets on itself with this[newFacet.name] = newFacet;. That means that what you want is actually web['files.comments'].delete currently.

I suspect this is just a bug and should be fixed in the future, though.


For possible fixes, maybe just set the field "comments" of the FilesFacet object, probably in it's constructor, to a FilesCommentsFacet object. Same for the usergroups.users facet!

great, indeed that's exactly the point... impressed from your quick root cause findings! :P

as a github newbie I may ask:
shall I close the issue now, since it is solved for me with your workaround - or keep it open? because it is still to verify how to handle this properly...

great, indeed that's exactly the point... impressed from your quick root cause findings! :P

I've gone through the library quite a number of times :P Recognized what the issue was from prior knowledge.

shall I close the issue now?

Nah, keep it open. One of the maintainers will see it and fix it (or label it), or someone else will submit a pull request fixing it. After that pull request is accepted, the maintainer should also close this issue.

I'd go ahead and submit the pull request but I'm busy for a little. If nobody gets around to it in a few hours, I'll probably do it then.

Thanks for this, y'all! I'll be following up just as soon as I fix one blocking issue…

Was this page helpful?
0 / 5 - 0 ratings