Parties (also called lobbies) are groups where players gather before entering a match. The party system allows your bot to create parties, join friends, manage members, and control party settings.
import rebootpy# Set to publicawait client.party.set_privacy(rebootpy.PartyPrivacy.PUBLIC)# Set to friends onlyawait client.party.set_privacy(rebootpy.PartyPrivacy.FRIENDS)# Set to privateawait client.party.set_privacy(rebootpy.PartyPrivacy.PRIVATE)# Check current privacyif client.party.privacy == rebootpy.PartyPrivacy.PRIVATE: print('Party is private')
try: party = await client.join_party('party-id-here') print(f'Joined party {party.id}')except rebootpy.PartyError: print('Could not join party')except rebootpy.Forbidden: print('Party is private')
@client.eventasync def event_friend_presence(before, after): friend = after.friend # Join when friend comes online if after.available and after.party and not after.party.private: await friend.join_party() print(f'Joined {friend.display_name}\'s party')
# Promote a member to leadermember = client.party.get_member('user-id')if member and client.party.me.leader: await member.promote() print(f'Promoted {member.display_name} to leader')
# Send a party messageawait client.party.send('Hello everyone!')@client.eventasync def event_party_message(message): print(f'{message.author.display_name}: {message.content}') if message.author.id != client.user.id: await message.reply('Thanks for your message!')
# Set readyawait client.party.me.set_ready(rebootpy.ReadyState.READY)# Set sitting outawait client.party.me.set_ready(rebootpy.ReadyState.SITTING_OUT)# Set not readyawait client.party.me.set_ready(rebootpy.ReadyState.NOT_READY)
@client.eventasync def event_party_member_join(member): print(f'{member.display_name} joined the party') # Welcome message await client.party.send(f'Welcome {member.display_name}!') # Check if it's the bot if member.id == client.user.id: print('Bot joined a new party')
@client.eventasync def event_party_member_promote(old_leader, new_leader): print(f'{new_leader.display_name} is now the party leader') # When bot becomes leader if new_leader.id == client.user.id: await client.party.set_privacy(rebootpy.PartyPrivacy.PUBLIC) await client.party.send('I\'m the leader now!')
@client.eventasync def event_party_invitation(invitation): print(f'Invited to party by {invitation.sender.display_name}') # Auto-accept if sender is a friend if client.get_friend(invitation.sender.id): await invitation.accept()
@client.eventasync def event_party_member_join(member): # If bot is leader and a friend joins, promote them if client.party.me.leader and client.get_friend(member.id): await member.promote() print(f'Promoted {member.display_name} to leader')
@client.eventasync def event_party_member_join(member): party = client.party # Kick if party is full if party.member_count > party.max_size and party.me.leader: await member.kick() await party.send('Party is full!')
# Public - Anyone can joinrebootpy.PartyPrivacy.PUBLIC# Friends onlyrebootpy.PartyPrivacy.FRIENDS# Friends and friends of friendsrebootpy.PartyPrivacy.FRIENDS_ALLOW_FRIENDS_OF_FRIENDS# Private - Invite onlyrebootpy.PartyPrivacy.PRIVATE