Jump to content
McKay Development

Recommended Posts

Posted

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.

Posted

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?

Posted (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 by Toxic
Posted (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 by Vanilla
Posted

 

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

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