Toxic Posted June 11, 2017 Report Posted June 11, 2017 I need some help with my bot.. so here is my problem.. I tried making an if statement like this: client.on('friendMessage', function (steamID, message) { if(steamID == '765611......'){ client.chatMessage(steamID, 'Working...'); } else { client.chatMessage(steamID, 'You are not my master!'); } }); But everytime i send the bot something it sends "Working..." but i want it to only respond with a command like !help or !test Any help or suggestions would be helpful. Quote
Dr. McKay Posted June 12, 2017 Report Posted June 12, 2017 Do need to also check the message if you want it to respond differently to different messages. Quote
Toxic Posted June 12, 2017 Author Report Posted June 12, 2017 Do need to also check the message if you want it to respond differently to different messages.Could you give an example of how i would do that? Quote
Toxic Posted June 12, 2017 Author Report Posted June 12, 2017 (edited) I found another way. But how would i do so it checks 2 steam id's in one if statement? I tried doing if(steamID == '76561197.....' && '76561.....'){ Edited June 12, 2017 by Toxic Quote
Vanilla Posted June 13, 2017 Report Posted June 13, 2017 (edited) if(steamID == '76561197.....' || steamID == '76561.....'){ In case if you want the bot accept user command and admin command, you can try this example, or using switch-case: var admin = "76561..."; //this is admin Steam ID client.on('friendMessage', function (steamID, message) { if((steamID == admin) && (message== "!command1")){ client.chatMessage(steamID, 'admin command 1'); } else if((steamID == admin) && (message== "!command2")){ client.chatMessage(steamID, 'admin command 2'); } else if(message== "!user1"){ client.chatMessage(steamID, 'user command 1'); } else if(message== "!help"){ client.chatMessage(steamID, '!help command'); } else { client.chatMessage(steamID, 'command not found, use !help'); } }); Edited June 13, 2017 by Vanilla Toxic 1 Quote
Toxic Posted June 13, 2017 Author Report Posted June 13, 2017 if(steamID == '76561197.....' || steamID == '76561.....'){ In case if you want the bot accept user command and admin command, you can try this example, or using switch-case: var admin = "76561..."; //this is admin Steam ID client.on('friendMessage', function (steamID, message) { if((steamID == admin) && (message== "!command1")){ client.chatMessage(steamID, 'admin command 1'); } else if((steamID == admin) && (message== "!command2")){ client.chatMessage(steamID, 'admin command 2'); } else if(message== "!user1"){ client.chatMessage(steamID, 'user command 1'); } else if(message== "!help"){ client.chatMessage(steamID, '!help command'); } else { client.chatMessage(steamID, 'command not found, use !help'); } }); Thanks works perfectly now 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.