Jump to content
McKay Development

Perport

Member
  • Posts

    16
  • Joined

  • Last visited

Posts posted by Perport

  1. 12 hours ago, Emily said:

     

    Thank you I checked the coding again and corrected my shortcomings now everyone can use other commands

     

    I have a question When the person leaves the group, he can still use that command, and someone who joins the group waits for a few minutes to use that command. Can we set this wait time?

    so I don't want him to use the command instantly when he leaves the group

     

    and the person joining the group should not wait, use that command directly

    I don't know cause every time someone uses special command bot loads the steam group .

    So issue might be steam sided I'll try to test it when I get on my computer 

    Edit:

    I couldn't find a solution about it so... Idk

  2. client.on("friendMessage", function (steamID, message) {
      if(message == "!test" || message == "!put these commands like this here you want only groupmembers to use" || message == "!anothercmd"){
    	getGroup("mygroupname",members => {
        	if (members.length > 0) {
            	if (message == "!test") {
                	if (members.includes(steamID.accountid)) {
                    	client.chatMessage(steamID, "Test Message");
                	}
                	else client.chatMessage(steamID, "You have to join our steam group");
            	}
                else if(message == "!membercmd2"){
                 	// 
                }
        	}
        	else {
            	client.chatMessage(steamID, "bot is still loading message");
        	}
    
        });
      }
      else if(message == "!help"){
        
      }
      else if (message == "!idk"){
        
      }
      else{
        console.log("Unknown command type \"!help\" to see available commands")
      }
    });

    This should I might have made some mistakes here and there I'm currently on mobile so I can't test it so try it and let me know.

    And Please indent this code or something it's starting to look weird.

  3. 6 hours ago, Emily said:

     

    ok ReferenceError: members is not defined i solved your mistake 

    my current problem is that I want one command to use only group member, doesn't recognize other commands

    I couldn't get that can you explain a little more ?

  4. 2 hours ago, Emily said:

     

    Thank you man how long have I been looking for this code now the person who is a member of the group is using it, but there is another problem, when this person leaves the group, he still continues to use that command.

    @Perport

     

    and I can't use this command after joining the group

    Then calling the getgroup function everytime someone messages you would help but probably slow down the response time but if you want to do it then this should work.

    And you can remove the getGroup from loggedOn event.

     

    function getGroup(groupName,callback) {
      groupmembers = [];
        community.getSteamGroup(groupName, (err, group) => {
            if (err) {
                console.log("Couldn't get the Group Retrying");
                setTimeout((groupName) => { getGroup(groupName,callback) }, 5000);
            } else group.getMembers((err, members) => {
                if (err) {
                    console.log("Couldn't get the Group Retrying..");
                    setTimeout((groupName) => { getGroup(groupName,callback) }, 5000);
                } else {
                    members.forEach(member => {
                        groupmembers.push(member.accountid);
                    });
                  callback(groupmembers);
                    console.log("Loaded The Group Members");
                }
            });
        });
    
    }
    
    client.on("friendMessage", function (steamID, message) {
    	getGroup("yourGroupName",members => {
        	if (members.length > 0) {
            	if (message == "!test") {
                	if (members.includes(steamID.accountid)) {
                    	client.chatMessage(steamID, "Test Message");
                	}
                	else client.chatMessage(steamID, "You have to join our steam group bla bla to use this bot or idk");
            	}
        	}
        	else {
            	client.chatMessage(steamID, "bot is still loading message");
        	}
        });
    });

     

  5. 5 hours ago, Emily said:
    
    if(groupmembers.includes(steamID.getSteamID64())){

     

    I'm still getting this error :(

    Cannot read property 'includes' of undefined

    
    client.on('loggedOn', () => {
        getGroup("mygroupname");
        client.setPersona(SteamUser.EPersonaState.LookingToTrade);
        client.gamesPlayed(["Test Bot",730]);
    });
    
    let groupmembers;
    function getGroup(groupName) {
        community.getSteamGroup(groupName, (err, group) => {
            if (err) {
                console.log("Couldn't get the Group Retrying");
                setTimeout(getGroup, 5000);
            } else group.getMembers((err, members) => {
                if (err) {
                    console.log("Couldn't get the Group Retrying..");
                    setTimeout(getGroup, 5000);
                } else {
                    groupmembers = members;
                }
            });
        });
    }
    
    client.on("friendMessage", function(steamID, message) {
        if (message == "!test") {
        if(groupmembers.includes(steamID.getSteamID64())){
            client.chatMessage(steamID, "Test Message");
        }
        else client.chatMessage(steamID,"You have to join our steam group bla bla to use this bot or idk");
        }})

     

    I did it this way but I get the error I said

    I justed tested it on a bigger group.

    It takes about a minute or so to load it so I though printing it to a console would help.

    Made the groupmembers var array from the beginning so it won't give you an error when someone types while it's still loading.

    Fixed few things about what bot does when it fails to get the group or its members.

    And made the array keep their accountids instead of steamid objects.

    Here is the code :

    client.on('loggedOn', () => {
        console.log("LoggedOn");
        getGroup("yourgroupname");
        client.setPersona(SteamUser.EPersonaState.LookingToTrade);
        client.gamesPlayed(["Test Bot", 730]);
    });
    let groupmembers = [];
    function getGroup(groupName) {
        community.getSteamGroup(groupName, (err, group) => {
            if (err) {
                console.log("Couldn't get the Group Retrying");
                setTimeout((groupName) => { getGroup(groupName) }, 5000);
            } else group.getMembers((err, members) => {
                if (err) {
                    console.log("Couldn't get the Group Retrying..");
                    setTimeout((groupName) => { getGroup(groupName) }, 5000);
                } else {
                    members.forEach(member => {
                        groupmembers.push(member.accountid);
                    });
                    console.log("Loaded The Group Members");
                }
            });
        });
    
    }
    
    client.on("friendMessage", function (steamID, message) {
        if (groupmembers.length > 0) {
            if (message == "!test") {
                if (groupmembers.includes(steamID.accountid)) {
                    client.chatMessage(steamID, "Test Message");
                }
                else client.chatMessage(steamID, "You have to join our steam group bla bla to use this bot or idk");
            }
        }
        else {
            client.chatMessage(steamID, "bot is still loading message");
        }
    });

    If you still have problems or questions feel free to ask

  6. 8 minutes ago, Emily said:

    Cannot read property 'includes' of undefined

    Did you call the getGroup function ? Like

    client.on("loggedOn",()=>{

    getGroup("reddit");

    }

  7. const steamCommunity = require('steamcommunity');
    
    let community = new steamCommunity({});
    
    community.login({
        "accountName": "name",
        "password": "password",
    },()=>{
      community.getSteamGroup("reddit",(err,group) => {
       if(err)console.log("Couldn't get the group");
        else group.join();
      });
    });

    this should do it

  8. 6 minutes ago, PlanZed said:

    I know this is a dumb question but how would I call the SteamID from the chat message?

    I have the code 

    
    client.chatMessage(steamID, "Setting up the trade offer for Test Item");
    const offer = manager.createOffer(steamID);

    Is this the correct way to call it?

    That should work but don't make the offer variable constant use var or let instead.

  9. const steamCommunity = require('steamcommunity');
    const client = new steamUser();
    let community = new SteamCommunity();
    let groupmembers;
    // https://steamcommunity.com/groups/reddit 's group name would be "reddit" as a string
    // call getGroup on your code on client loggedOn event or somewhere else you want
    function getGroup(groupName) {
        community.getSteamGroup(groupName, (err, group) => {
            if (err) {
                console.log("Couldn't get the Group Retrying");
                setTimeout(getGroup, 5000);
            } else group.getMembers((err, members) => {
                if (err) {
                    console.log("Couldn't get the Group Retrying..");
                    setTimeout(getGroup, 5000);
                } else {
                    groupmembers = members;
                }
            });
        });
    }
    
    client.on("friendMessage", (steamID,msg) => {
      if(groupmembers.includes(steamID.getSteamID64())){
        //do your thing
      }
      else client.chatMessage(steamID,"You have to join our steam group bla bla to use this bot or idk");
    });

    this should work if you still have problems please let me know

  10. If the game is telling you that the blueprint is invalid, either you're trying to craft the wrong items or something weird is going on with the GC that we can't do anything about.

     

    No, the only ways to update your inventory on steamcommunity.com are to launch/quit a game, complete a trade offer containing items in that inventory, or start a real-time trading session.

    Thanks for replying so we have nothing to do except waiting.

  11. Try leaving out the recipe ID.

    I tried that before but yesterday when I tried to do it I was able to craft few times before it started giving errors again.

    I opened my game after that and tried to craft I got an error which was "Crafting Failed: No Matching Blueprint".

    It's probably a temporary craft ban or something like that is there anyway I can get around that ?

     

    And is there a way to make GC update my steamcommunity backpack without making gamesPlayed([]) then gamesPlayed(440) ?

  12. Hi,I'm having issues when I try to craft a class weapon other stuff works like crafting metals,tokens etc .But when I try to craft a class weapon craftingComplete event returns the recipe as -1 which is error.I'm getting my items from steamcommunity and I confirmed that arrays or ids are empty.Thanks in advance.

    
    tf2.craft([scrapid, pda2tokenid, spytokenid], 11)
    
    
    
    
×
×
  • Create New...