xMistt / rebootpy

Continuation of fortnitepy by Terbau - An asynchronous library for interacting with Fortnite and EpicGames' API and XMPP services.
MIT License
15 stars 6 forks source link

set_squad_assignments Hide doesn't work #11

Open minion6011 opened 3 weeks ago

minion6011 commented 3 weeks ago
image

When I use set_squad_assignments with hide=True on a member the member and the bot will become the leader of the lobby

xMistt commented 3 weeks ago

ill look into it

xMistt commented 2 weeks ago

It seems to work fine for me, I can hide myself while in the bots party, can you share the code you're using to hide yourself?

minion6011 commented 2 weeks ago
@discord_bot.command()
async def test(ctx, name, value:str):
    #https://rebootpy.readthedocs.io/en/latest/api.html?highlight=party#rebootpy.ClientParty.set_squad_assignments
    try:
        fn_client = online_fn_client[str(ctx.author.id)]
        user = await fn_client.fetch_user(name)
        party_user = fn_client.party.get_member(user.id)
        assignments_value = {}
        if value == "true":
            assignments_value[party_user] = rebootpy.SquadAssignment(hidden=True)
        elif value == "false":
            assignments_value[party_user] = rebootpy.SquadAssignment(hidden=False)
        await fn_client.party.set_squad_assignments(assignments=assignments_value)
    except Exception as e:
        print(e)
xMistt commented 1 week ago

Using that same code seems to work fine for me, are you running 0.9.3 or the latest GitHub version and is the bot party leader?

@bot.command()
async def hide2(ctx, name, value: str) -> None:
    try:
        fn_client = bot
        user = await fn_client.fetch_user(name)
        party_user = fn_client.party.get_member(user.id)
        assignments_value = {}
        if value == "true":
            assignments_value[party_user] = rebootpy.SquadAssignment(
                hidden=True
            )
        elif value == "false":
            assignments_value[party_user] = rebootpy.SquadAssignment(
                hidden=False
            )
        await fn_client.party.set_squad_assignments(
            assignments=assignments_value
        )
    except Exception as e:
        print(e)

image image

I'm going to add a .hide() function to PartyMember to make it simpler and please let me know if that fixes the issue for you, I was planning on doing this sometime in the future anyway.

minion6011 commented 1 week ago

No, I was using an old version, now I updated the version to 0.9.3. The command runs without errors but it does not work, could it be a problem if it is a Lobby Bot network and there is no auth.json file?

minion6011 commented 1 week ago

the error is because asyncio.Lock() / client_fn.party.edit_lock.locked() that return false, in the code of the library is used in party.py in refresh_squad_assignments:

check = not self.edit_lock.locked() if could_be_edit else True
if check:
        #code...
xMistt commented 1 week ago

Thanks for letting me know, I'll look into it again.

xMistt commented 2 days ago

Do you do anything specific before attempting to hide party members? It's never locked for me and I tried multiple times. Also, does hiding always never work?

minion6011 commented 2 days ago

for me it is locked because the bot is executed inside a function because it is a starbot