Jump to content
McKay Development

inviteToGroup


Flashyg1

Recommended Posts

Since you haven't posted any code I'm unsure how you're using the method. So I'll show you how I usually do it.

Let's say you want to invite the user as soon as they become friends with yout bot, you can do it as follows:

client.on('friendRelationship', (steamID, relationship) => {
    switch(relationship) {
        //The bot received a friend request from another Steam user
        case 2:
            console.log(`Bot ${client.steamID.getSteamID64()} received a friend request from user ${steamID}.`);
        
            client.addFriend(steamID, (err) => {
                if(err) {
                    console.log(`Error adding user ${steamID}.`);
                } else {
                    client.getPersonas([steamID], (err, personas) => {
                        var persona = personas[steamID.getSteamID64()];
                        var name = persona ? persona.player_name : ("[" + steamID.getSteamID64() + "]");
                        client.chatMessage(steamID, `Greetings ${name}! ${config.steam.messages.new_friend}`);
                    });
                    console.log(`Bot ${client.steamID.getSteamID64()} accepted user ${steamID}'s friend request.`);
                }
            });
            break;
        //The bot is now friends with another Steam user
        case 3:
            //Invite that user to our Steam group
            client.inviteToGroup(steamID, config.steam.groupID);
        
            console.log(`Bot ${client.steamID.getSteamID64()} invited user ${steamID} to our Steam group.`);
            break;
        default:
            break;
    }
});

The inviteToGroup methods takes two arguments, the SteamID of the user you wish to invite and the groupID for the group.

The SteamID is retrieved from the friendRelationship event. You'll have to store your Steam group ID in a variable or in a separate file. I store mine in a JSON config file.

If you don't have the groupID you can find it by replacing <GroupName> in this url https://steamcommunity.com/groups/<GroupName>/memberslistxml/?xml=1 with the name of your Steam group. Then you'll be able to extract the groupID from the XML file in your browser. 

 

I hope this helps!

Link to comment
Share on other sites

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