TomYoki Posted May 1, 2017 Report Posted May 1, 2017 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 XIs this somehow possible? Thanks in advance! 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); } }); TomYoki 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.