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

Cannot read property 'use' of undefined #41

Open
Mattw11486 opened this issue Oct 31, 2022 · 0 comments
Open

Cannot read property 'use' of undefined #41

Mattw11486 opened this issue Oct 31, 2022 · 0 comments

Comments

@Mattw11486
Copy link

Mattw11486 commented Oct 31, 2022

I am trying to add a simple points/karma system to my slack bot
https://github.com/paircast/mlh-webex-bot-karma
however I am getting an error trying to use the middleware

image

` controller.middleware.heard.use(function(bot, message, next){
let text = message.text.split(" ");
let found = false;
if(text[0] == "sdpoints"){
// perform the code that adds points to a user
}else if(text[0] == "sdremove"){
// perform the code to remove a specific user
}else if(text[0] == "sdreset"){
// perform the code to set the users points to zero
}else if(text[0] == "sduser"){
// perform the code to add a new user
}else if(text[0] == "sdtally"){
// perform the code to tally up the results so far.
}else if(text[0] == "sdhelp"){
//send the help response
message.user_profile = "Here is a list of things you can say:\n1. /points '# of points' 'Name of person'\n2. /tally\n3. /remove 'users name'\n4. /user 'new users name'\n5. /reset";
next();
}else{
//send by default the help response
}
});

controller.hears(['sdpoints (.)', 'sdremove (.)', 'sdreset', 'sduser (.*)', 'sdtally', 'sdhelp'], 'direct_message,direct_mention', function(bot, message){
console.log("Made it to the hears reply section", message.user_profile);
bot.reply(message, message.user_profile);
});`

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

1 participant