Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant