Example #1
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)
Example #2
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)
Example #3
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
        ]
Example #4
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)
Example #5
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)