Ejemplo n.º 1
0
    def modify_current_user(self, args: dict) -> typing.Any:
        """Modify current discord User


        Parameters
        ----------
        args: typing.Dict
                A dictionary containing the changes to the current user. This has to be either
                their username, avatar or both

        Example
        -------
        ```py
        >>> some_api_instance.modify_current_user({'username' : 'FroggyMan', 'avatar' : 'https://cdn.discordapp.com/avatars/753561575532658738/0cf89f88a3ba4e226c6f1c72a9242dd8.png'})

            User(id=753561575532658738, username=Zenora, discriminator=6423, avatar_url=https://cdn.discordapp.com/avatars/753561575532658738/380c68e7a6752e347ed875c2e11a05c4.png?size=1024,
            flags=0, mention=<@753561575532658738>, bot=True, mfa_enabled=True, locale=en-US, verified=True,)
        ```

        Returns
        -------
        zenora.users.User
                Zenora user object

        """
        if "avatar" in args:
            args["avatar"] = zenora.File(args["avatar"]).data
        response = Query(self.token, self.token_type).modify_me(args)
        return model_factory.parse_user(response=response, app=self)
Ejemplo n.º 2
0
    def get_channel(self, snowflake: int) -> typing.Any:
        """Fetch Dicord Channel

        This has to be the channel snowflake ID


        Parameters
        ----------

        snowflake: int
                The channel ID of the specific channel you want to fetch

        Returns
        -------
        zenora.channels.GuildTextChannel
                Zenora guild text channel object

        zenora.channels.GuildVoiceChannel
                Zenora guild voice channel object

        zenora.channels.DMTextChannel
                Zenora DM text channel object
        """
        response = Query(self.token, self.token_type).channel(snowflake)
        return model_factory.parse_channel(response)
Ejemplo n.º 3
0
    def create_dm(self, recipient_id: int) -> zenora.channels.DMTextChannel:
        """Creates DM text channel with a specified user according to snowflake ID

        Parameters
        ----------
        recipient_id: int
                The snowflake ID of the user with whom the DM would be opened

        Returns
        -------
        zenora.channels.DMTextChannel
                Zenora DM Text channel object

        """
        if not self.testing:
            response = Query(self.token,
                             self.token_type).create_dm(recipient_id)
        else:
            response = {
                "id":
                "753798803806748883",
                "last_message_id":
                "754896488441708595",
                "type":
                1,
                "recipients": [{
                    "id": "406882130577063956",
                    "username": "******",
                    "avatar": "aa6fb65225a58726292323435512925d",
                    "discriminator": "9441",
                    "public_flags": 0,
                }],
            }
        return model_factory.parse_channel(response=response, app=self)
Ejemplo n.º 4
0
    def get_user(self, snowflake: int) -> typing.Any:
        """Fetch Dicord User

        This has to be the user's snowflake ID


        Parameters
        ----------

        snowflake: int
                The ID of the Discord User

        Returns
        -------
        zenora.users.User
                Zenora user object

        """
        if not self.testing:
            response = Query(self.token, self.token_type).user(snowflake)
        else:
            response = {
                "id": "479287754400989217",
                "username": "******",
                "avatar": "9ab336b1e0506f6549d708591991d195",
                "discriminator": "4346",
                "public_flags": 128,
            }
        return model_factory.parse_user(response=response, app=self)
Ejemplo n.º 5
0
    def get_current_user(self) -> typing.Any:
        """Fetch the current Dicord User


        Returns
        -------
        zenora.users.User
                Zenora user object

        """
        response = Query(self.token, self.token_type).current_user()
        return model_factory.parse_user(response=response, app=self)
Ejemplo n.º 6
0
    def get_my_dms(self) -> typing.List:
        """Fetch the current Dicord user's DM channels


        Returns
        -------
        typing.List
                List of Zenora DMTextChannel objects

        """

        if not self.testing:
            response = Query(self.token, self.token_type).current_user_dms()
        else:
            response = [
                {
                    "id":
                    "753798803806748883",
                    "last_message_id":
                    "754896488441708595",
                    "type":
                    1,
                    "recipients": [{
                        "id": "406882130577063956",
                        "username": "******",
                        "avatar": "aa6fb65225a58726292323435512925d",
                        "discriminator": "9441",
                        "public_flags": 0,
                    }],
                },
                {
                    "id":
                    "736468127210012732",
                    "last_message_id":
                    "736469839983542334",
                    "type":
                    1,
                    "recipients": [{
                        "id": "503641822141349888",
                        "username": "******",
                        "avatar": "a_3df953ed0d85ebc1877762ed9fe29eae",
                        "discriminator": "5555",
                        "public_flags": 128,
                    }],
                },
            ]
        return [
            model_factory.parse_channel(response=i, app=self) for i in response
        ]
Ejemplo n.º 7
0
    def modify_channel(self, snowflake: int,
                       params: typing.Dict) -> typing.Any:
        """Modify Discord Guild Channel

        The snowflake parameter has to be the channel snowflake ID

        Parameters
        ----------
        snowflake : int
                The snowflake ID of the channel.

        args: typing.Dict
                A dictionary containing the changes to the current channel. Check this
                link for all the changes applicable https://discord.com/developers/docs/resources/channel#modify-channel
        """
        response = Query(self.token,
                         self.token_type).modify_channel(snowflake, params)
        return model_factory.parse_channel(response=response, app=self)
Ejemplo n.º 8
0
    def get_user(self, snowflake: int) -> typing.Any:
        """Fetch Dicord User

        This has to be the user's snowflake ID


        Parameters
        ----------

        snowflake: int
                The channel ID of the specific channel you want to fetch

        Returns
        -------
        zenora.users.PartialUser
                Zenora partial user object

        """
        response = Query(self.token, self.token_type).user(snowflake)
        return model_factory.parse_user(response, snowflake)
Ejemplo n.º 9
0
    def get_user(self, snowflake: int) -> typing.Any:
        """Fetch Dicord User

        This has to be the user's snowflake ID


        Parameters
        ----------

        snowflake: int
                The ID of the Discord User

        Returns
        -------
        zenora.users.User
                Zenora user object

        """
        response = Query(self.token, self.token_type).user(snowflake)
        return model_factory.parse_user(response=response, app=self)
Ejemplo n.º 10
0
    def get_current_user(self) -> typing.Any:
        """Fetch the current Dicord User


        Returns
        -------
        zenora.users.User
                Zenora user object

        """
        if not self.testing:
            response = Query(self.token, self.token_type).current_user()
        else:
            response = {
                "id": "479287754400989217",
                "username": "******",
                "avatar": "9ab336b1e0506f6549d708591991d195",
                "discriminator": "4346",
                "public_flags": 128,
            }
        return model_factory.parse_user(response=response, app=self)
Ejemplo n.º 11
0
    def get_channel(self, snowflake: int) -> typing.Any:
        """Fetch Dicord Channel

        This has to be the channel snowflake ID


        Parameters
        ----------

        snowflake: int
                The channel ID of the specific channel you want to fetch

        Returns
        -------
        zenora.channels.GuildTextChannel
                Zenora guild text channel object

        zenora.channels.GuildVoiceChannel
                Zenora guild voice channel object

        zenora.channels.DMTextChannel
                Zenora DM text channel object
        """
        if not self.testing:
            response = Query(self.token, self.token_type).channel(snowflake)
        else:
            response = {
                "id": "753859569859690509",
                "last_message_id": "754623102561812511",
                "type": 0,
                "name": "general",
                "position": 4,
                "parent_id": "753859569859690506",
                "topic": None,
                "guild_id": "753859568764977194",
                "permission_overwrites": [],
                "nsfw": False,
                "rate_limit_per_user": 0,
            }
        return model_factory.parse_channel(response=response, app=self)
Ejemplo n.º 12
0
    def modify_current_user(self, args: dict) -> typing.Any:
        """Modify current discord User


        Parameters
        ----------
        args: typing.Dict
                A dictionary containing the changes to the current user. This has to be either
                their username, avatar or both

        Example
        -------
        .. code-block:: python


            >>> some_api_instance.modify_current_user({'username' : 'FroggyMan', 'avatar' : 'https://cdn.discordapp.com/avatars/753561575532658738/0cf89f88a3ba4e226c6f1c72a9242dd8.png'})
            User(id=753561575532658738, username=Zenora, discriminator=6423, avatar_url=https://cdn.discordapp.com/avatars/753561575532658738/380c68e7a6752e347ed875c2e11a05c4.png?size=1024,
            flags=0, mention=<@753561575532658738>, bot=True, mfa_enabled=True, locale=en-US, verified=True,)


        Returns
        -------
        zenora.users.User
                Zenora user object

        """
        if not self.testing:
            if "avatar" in args:
                args["avatar"] = zenora.File(args["avatar"]).data
            response = Query(self.token, self.token_type).modify_me(args)
        else:
            response = {
                "id": "479287754400989217",
                "username": "******",
                "avatar": "9ab336b1e0506f6549d708591991d195",
                "discriminator": "4346",
                "public_flags": 128,
            }
        return model_factory.parse_user(response=response, app=self)