Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 97371

Copy value out of users input to another channel

$
0
0

I am working on a chatbot for school that solves problems in my school. So basically I'm stuck on this part because I have no idea how to do this...

  • I want to check if a certain value in a sentence is equal to a value in my array.
  • If it is equal to a value in my array, then I want my chatbot to write a message to another channel containing that variable

So lets say I have the sentence:

Hi, I have a problem in classroom 108

The value "classroom 108" is equal to the value "classroom 108" in my array.

   var classroom= [
    {
        L108: ["classroom 108","L108"]
    },{
        L208: ["classroom 208","L208"]
    }
];

So now I want to write a message to another channel containing the variable "L108".

function handleMessage(message) {
     classroom.forEach((value, index) => {
        if (message.includes(classroom)) {
            classroom();
            console.log(message);
        };
    })
};
function classroom(message) {
    const params = {
        icon_emoji: ':smiley:'
    }
    textchannel = probleemoplosser + ", een docent heeft een probleem met het " + probleem + " in ",classroom, params;
    reactie =  "Top, ik heb het doorgegeven aan " + naam;
    bot.postMessageToChannel( otherchannel,textchannel,params);
    bot.postMessageToChannel('general',reactie, params);
};

I don't have much experience with JavaScript so any help is welcome...thanks in advance!<3


Viewing all articles
Browse latest Browse all 97371

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>