Lobadzip Posted April 30, 2017 Report Posted April 30, 2017 Hi guys! At the moment I'm working on a chat-bot Steam, the essence of which will be giving out things for winning in the game, and all this will happen right in the bot, but I ran into the problem that I can not get data from the user: client.on('friendOrChatMessage', (senderID, message) => { if (message.indexOf("/bet %user number%") == 0){ client.chatMessage(senderID, 'Your bet is: ' + %user number%); } }); where %user number% is the number that the user enters, but I do not know how it can be implemented :C Is it even possible to do this and how? Please help me! Quote
SunriseM Posted May 1, 2017 Report Posted May 1, 2017 You can use "split" to convert the string to array and get the part you want. Example: client.on('friendOrChatMessage', (senderID, message) => { //Example Message: /bet 45 var arrmsg = message.split(" ") //arrmsg = ["/bet","45"] var userNumber = arrmsg[1] if (message.indexOf("/bet") == 0){ client.chatMessage(senderID, 'Your bet is: ' + userNumber); } }); You will have to add other things like be sure that input has /bet [number], verify the number can be used, etc Lobadzip 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.