Jump to content
McKay Development

Recommended Posts

Posted

So I was wondering if it is possible with any of McKay's modules to read numbers and maybe even words out of chat messages.

Say I'd like to search if there is this item in bots inventory and I type !search <item name> or if I want to buy keys !buykey X

Is this somehow possible?

 

Thanks in advance!

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

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...