Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError: Unexpected token for starter-slapp-app #73

Closed
abinashmohanty opened this issue Mar 1, 2017 · 1 comment
Closed

SyntaxError: Unexpected token for starter-slapp-app #73

abinashmohanty opened this issue Mar 1, 2017 · 1 comment

Comments

@abinashmohanty
Copy link

Used this script for user onboarding; basically whenever someone joins our default slack channel, the bot should send a direct message to the user separately. It's throwing some error right now..

slapp.match((msg) => {
  if (!msg.isMessage() || msg.body.event.subtype !== 'channel_join') {
    return false
  }
  isChannel('general', msg, (err, yes) => {
    if (err) return console.log('Error looking for general channel', err)
    if (yes) {
       
        slapp.message('direct_message',(msg)=>{
          slapp.client.im.open({token,user:${msg.meta.user_id}},(err,data){
            if(err){
              return console.log(err);
            }else {
              msg.say({ text: ` Welcome to slack` })
            }   
      })
    }
  })
  return true
})

Getting the following error..

/usr/src/app/server.js:117
slapp.client.im.open({token,user:${msg.meta.user_id}},(err,data){
^
SyntaxError: Unexpected token

You can view the live code being inserted in between 108 - 127 on https://github.com/abinashmohanty/user-onboarding-slapp-app/blob/master/server.js

@selfcontained
Copy link
Contributor

I believe we've resolved this in another support medium, but the error was around the syntax on this line:

slapp.client.im.open({token,user:${msg.meta.user_id}},(err,data){

Should have been something like:

slapp.client.im.open({token,user: msg.meta.user_id},(err,data){

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants