Esempio n. 1
0
    def to_mock(self):
        """Returns an AsyncMock matching the spec for this class"""
        # we still have to set stuff manually but changing values is nicer
        mock = AsyncMock(name="Message Mock", spec=discord.Message)

        # Author section
        mock.author = MockedMember(
            name=self.author["name"],
            member_id=self.author["id"],
            is_bot=self.author["is_bot"],
        ).to_mock()

        # Guild options and 'is_in_guild' are mutually exclusive
        if not self.is_in_guild:
            mock.guild = None
        else:
            mock.guild = MockedGuild(name=self.guild["name"], guild_id=self.guild["id"]).to_mock()

        mock.channel = MockedChannel().to_mock()
        mock.created_at = datetime.datetime.now()

        mock.id = self.message_id
        mock.content = self.content
        mock.clean_content = self.clean_content

        return mock