Jump to content
McKay Development

Recommended Posts

Posted

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!

Posted

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

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...