How to use the fortnitepy.errors.Forbidden 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 / client.py View on Github external
raise NotFound('The specified account does not exist.')

            m = 'errors.com.epicgames.friends.duplicate_friendship'
            if exc.message_code == m:
                raise DuplicateFriendship('This friendship already exists.')

            m = 'errors.com.epicgames.friends.friend_request_already_sent'
            if exc.message_code == m:
                raise FriendshipRequestAlreadySent(
                    'A friendship request already exists for this user.'
                )

            m = ('errors.com.epicgames.friends.'
                 'cannot_friend_due_to_target_settings')
            if exc.message_code == m:
                raise Forbidden('You cannot send friendship requests to '
                                'this user.')

            raise
github Terbau / fortnitepy / fortnitepy / party.py View on Github external
Kicks this member from the party.

        Raises
        ------
        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 / party.py View on Github external
async def chatban_member(self, user_id: str, *,
                             reason: Optional[str] = None) -> None:
        if not self.me.leader:
            raise Forbidden('Only leaders can ban members from the chat.')

        if user_id in self._chatbanned_members:
            raise ValueError('This member is already banned')

        room = self.client.xmpp.muc_room
        for occupant in room.members:
            if occupant.direct_jid.localpart == user_id:
                self._chatbanned_members[user_id] = self.members[user_id]
                await room.ban(occupant, reason=reason)
                break
        else:
            raise NotFound('This member is not a part of the party.')
github Terbau / fortnitepy / fortnitepy / client.py View on Github external
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.')

            await self.party._leave()
            party = self.construct_party(party_data)
            self.party = party

            future = asyncio.ensure_future(self.wait_for(
                'party_member_join',
                check=lambda m: m.id == self.user.id and party.id == m.party.id
            ), loop=self.loop)

            try:
                await self.http.party_join_request(party_id)
            except HTTPException as e:
                if not future.cancelled():
                    future.cancel()
github Terbau / fortnitepy / fortnitepy / party.py View on Github external
Resends an invite with a new notification popping up for the receiving
        user.

        Raises
        ------
        Forbidden
            Attempted to resend an invite not sent by the client.
        HTTPException
            Something went wrong while requesting to resend the invite.
        """
        if self.client.is_creating_party():
            return

        if self.sender.id == self.party.me.id:
            raise Forbidden('You can only resend invites sent by the client.')

        await self.client.http.party_send_ping(
            self.receiver.id
        )
github Terbau / fortnitepy / fortnitepy / party.py View on Github external
Forbidden
            The invited user is not friends with the client.
        HTTPException
            Something else went wrong when trying to invite the user.

        Returns
        -------
        :class:`SentPartyInvitation`
            Object representing the sent party invitation.
        """
        if self.client.is_creating_party():
            return

        friend = self.client.get_friend(user_id)
        if friend is None:
            raise Forbidden('Invited user is not friends with the client')

        return await self._invite(friend)
github Terbau / fortnitepy / fortnitepy / client.py View on Github external
if isinstance(end_time, datetime.datetime):
            end_time = int((end_time - epoch).total_seconds())
        elif isinstance(end_time, SeasonEndTimestamp):
            end_time = end_time.value

        tasks = [
            self.fetch_profile(user_id, cache=True),
            self.http.stats_get_v2(
                user_id,
                start_time=start_time,
                end_time=end_time
            )
        ]
        results = await asyncio.gather(*tasks)
        if results[1] == '':
            raise Forbidden('This user has chosen to be hidden '
                            'from public stats.')

        return StatsV2(*results) if results[0] is not None else None
github Terbau / fortnitepy / fortnitepy / friend.py View on Github external
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 / party.py View on Github external
Cancels the invite. The user will see an error message saying something
        like ``'s party is private.``

        Raises
        ------
        Forbidden
            Attempted to cancel an invite not sent by the client.
        HTTPException
            Something went wrong while requesting to cancel the invite.
        """
        if self.client.is_creating_party():
            return

        if self.sender.id != self.party.me.id:
            raise Forbidden('You can only cancel invites sent by the client.')

        await self.client.http.party_delete_invite(
            self.party.id,
            self.receiver.id
        )
github Terbau / fortnitepy / fortnitepy / party.py View on Github external
Parameters
        ----------
        value: :class:`bool`
            What to set the fill status to.

            **True** sets it to 'Fill'
            **False** sets it to 'NoFill'

        Raises
        ------
        Forbidden
            The client is not the leader of the party.
        """
        if self.me is not None and not self.me.leader:
            raise Forbidden('You have to be leader for this action to work.')

        prop = self.meta.set_fill(val=value)
        if not self.edit_lock.locked():
            return await self.patch(updated=prop)