How to use the fortnitepy.errors.PartyError function in fortnitepy

To help you get started, we’ve selected a few fortnitepy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Terbau / fortnitepy / fortnitepy / party.py View on Github external
async def _invite(self, friend: Friend) -> None:
        if friend.id in self.members:
            raise PartyError('User is already in you party.')

        if len(self.members) == self.max_size:
            raise PartyError('Party is full')

        await self.client.http.party_send_invite(self.id, friend.id)

        invite = SentPartyInvitation(
            self.client,
            self,
            self.me,
            self.client.store_user(friend.get_raw()),
            {'sent_at': datetime.datetime.utcnow()}
        )
        return invite
github Terbau / fortnitepy / fortnitepy / client.py View on Github external
raised if ``check_party`` is set to ``False``.

            .. warning::

                Since the client has to leave its current party before joining
                another one, a new party is automatically created if this
                error is raised. Use ``check_private`` with caution.

        Returns
        -------
        :class:`ClientParty`
            The party that was just joined.
        """
        async with self._join_party_lock:
            if party_id == self.party.id:
                raise PartyError('You are already a member of this party.')

            try:
                party_data = await self.http.party_lookup(party_id)
            except HTTPException as e:
                if e.message_code == ('errors.com.epicgames.social.'
                                      'party.party_not_found'):
                    raise NotFound(
                        'Could not find a party with the id {0}'.format(
                            party_id
                        )
                    )
                raise

            if check_private:
                if party_data['config']['joinability'] == 'INVITE_AND_FORMER':
                    raise Forbidden('You can\'t join a private party.')
github Terbau / fortnitepy / fortnitepy / xmpp.py View on Github external
async def send_party_message(self, content: str) -> None:
        if self.muc_room is None:
            raise PartyError('Can\'t send message. Reason: No party found')

        msg = aioxmpp.Message(
            type_=aioxmpp.MessageType.GROUPCHAT
        )
        msg.body[None] = content
        self.muc_room.send_message(msg)
github Terbau / fortnitepy / fortnitepy / party.py View on Github external
.. warning::

            A bug within the fortnite services makes it not possible to join a
            private party you have already been a part of before.

        Raises
        ------
        Forbidden
            You attempted to join a private party you've already been a part
            of before.
        HTTPException
            Something went wrong when accepting the invitation.
        """
        if self.net_cl != self.client.net_cl and self.client.net_cl != '':
            raise PartyError('Incompatible net_cl')

        await self.client.join_to_party(self.party.id, check_private=False)
        asyncio.ensure_future(
            self.client.http.party_delete_ping(self.sender.id),
            loop=self.client.loop
        )
github Terbau / fortnitepy / fortnitepy / party.py View on Github external
async def _invite(self, friend: Friend) -> None:
        if friend.id in self.members:
            raise PartyError('User is already in you party.')

        if len(self.members) == self.max_size:
            raise PartyError('Party is full')

        await self.client.http.party_send_invite(self.id, friend.id)

        invite = SentPartyInvitation(
            self.client,
            self,
            self.me,
            self.client.store_user(friend.get_raw()),
            {'sent_at': datetime.datetime.utcnow()}
        )
        return invite
github Terbau / fortnitepy / fortnitepy / party.py View on Github external
Forbidden
            You are not the leader of the party.
        PartyError
            You are already partyleader.
        HTTPException
            Something else went wrong when trying to promote this member.
        """
        if self.client.is_creating_party():
            return

        if not self.party.me.leader:
            raise Forbidden('You must be the party leader to perform this '
                            'action')

        if self.client.user.id == self.id:
            raise PartyError('You are already the leader')

        await self.client.http.party_promote_member(self.party.id, self.id)
github xMistt / fortnitepy-bot / fortnite.py View on Github external
user = await client.fetch_profile(epic_username)

        if user is not None:
            epic_friend = client.get_friend(user.id)
        else:
            epic_friend = None
            await ctx.send(f'Failed to find user with the name: {epic_username}.')
            print(crayons.red(f"[PartyBot] [{time()}] [ERROR] "
                              f"Failed to find user with the name: {epic_username}."))

    if isinstance(epic_friend, fortnitepy.Friend):
        try:
            await epic_friend.invite()
            await ctx.send(f'Invited {epic_friend.display_name} to the party.')
            print(f"[PartyBot] [{time()}] [ERROR] Invited {epic_friend.display_name} to the party.")
        except fortnitepy.errors.PartyError:
            await ctx.send('Failed to invite friend as they are either already in the party or it is full.')
            print(crayons.red(f"[PartyBot] [{time()}] [ERROR] "
                              "Failed to invite to party as friend is already either in party or it is full."))
    else:
        await ctx.send('Cannot invite to party as the friend is not found.')
        print(crayons.red(f"[PartyBot] [{time()}] [ERROR] "
                          "Failed to invite to party as the friend is not found."))
github Terbau / fortnitepy / fortnitepy / party.py View on Github external
Forbidden
            You are not the leader of the party.
        PartyError
            You attempted to kick yourself.
        HTTPException
            Something else went wrong when trying to kick this member.
        """
        if self.client.is_creating_party():
            return

        if not self.party.me.leader:
            raise Forbidden('You must be the party leader to perform this '
                            'action')

        if self.client.user.id == self.id:
            raise PartyError('You can\'t kick yourself')

        try:
            await self.client.http.party_kick_member(self.party.id, self.id)
        except HTTPException as e:
            m = 'errors.com.epicgames.social.party.party_change_forbidden'
            if e.message_code == m:
                raise Forbidden(
                    'You dont have permission to kick this member.'
                )
            raise
github Terbau / fortnitepy / fortnitepy / friend.py View on Github external
------
        PartyError
            Party was not found.
        Forbidden
            The party you attempted to join was private.
        HTTPException
            Something else went wrong when trying to join the party.

        Returns
        -------
        :class:`ClientParty`
            The clients new party.
        """
        _pre = self.last_presence
        if _pre is None:
            raise PartyError('Could not join party. Reason: Party not found')

        if _pre.party.private:
            raise Forbidden('Could not join party. Reason: Party is private')

        return await _pre.party.join()
github Terbau / fortnitepy / fortnitepy / presence.py View on Github external
Raises
        ------
        PartyError
            You are already a member of this party.
        Forbidden
            The party is private.
        HTTPException
            Something else went wrong when trying to join this party.

        Returns
        -------
        :class:`ClientParty`
            The party that was just joined.
        """
        if self.client.party.id == self.id:
            raise PartyError('You are already a member of this party.')

        if self.private:
            raise Forbidden('You cannot join a private party.')

        return await self.client.join_to_party(self.id)