botkit-docs icon indicating copy to clipboard operation
botkit-docs copied to clipboard

Cannot read property 'use' of undefined

Open Mattw11486 opened this issue 2 years ago • 0 comments

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); });`

Mattw11486 avatar Oct 31 '22 18:10 Mattw11486