Repository: Rapptz/discord.py
File: discord/message.py (Python)

Code before:
        self.mention_everyone: bool = data['mention_everyone']
        self.tts: bool = data['tts']
        self.content: str = data['content']
        self.nonce: Optional[Union[int, str]] = data.get('nonce')
        self.position: Optional[int] = data.get('position')
        self.application_id: Optional[int] = utils._get_as_snowflake(data, 'application_id')
        self.stickers: List[StickerItem] = [StickerItem(data=d, state=state) for d in data.get('sticker_items', [])]

        try:
            # if the channel doesn't have a guild attribute, we handle that
            self.guild = channel.guild
        except AttributeError:
            self.guild = state._get_guild(utils._get_as_snowflake(data, 'guild_id'))

        self._thread: Optional[Thread] = None

        if self.guild is not None:
            try:
                thread = data['thread']
            except KeyError:
                pass
            else:
                self._thread = self.guild.get_thread(int(thread['id']))

                if self._thread is not None:
                    self._thread._update(thread)
                else:
                    self._thread = Thread(guild=self.guild, state=state, data=thread)

        self.interaction: Optional[MessageInteraction] = None

        # deprecated
        try:
            interaction = data['interaction']
        except KeyError:
            pass
        else:
            self.interaction = MessageInteraction(state=state, guild=self.guild, data=interaction)

        self.interaction_metadata: Optional[MessageInteractionMetadata] = None
        try:
            interaction_metadata = data['interaction_metadata']
        except KeyError:
            pass
        else:
            self.interaction_metadata = MessageInteractionMetadata(state=state, guild=self.guild, data=interaction_metadata)

        try:
            ref = data['message_reference']
        except KeyError:
            self.reference = None

Review comment (suggestion):
I can do it myself but it might be worth adding `@discord.utils.deprecated` to the older attribute by changing it into a read-only property to apply the decorator.

Code after:
        self.stickers: List[StickerItem] = [StickerItem(data=d, state=state) for d in data.get('sticker_items', [])]

        try:
            # if the channel doesn't have a guild attribute, we handle that
            self.guild = channel.guild
        except AttributeError:
            self.guild = state._get_guild(utils._get_as_snowflake(data, 'guild_id'))

        self._thread: Optional[Thread] = None

        if self.guild is not None:
            try:
                thread = data['thread']
            except KeyError:
                pass
            else:
                self._thread = self.guild.get_thread(int(thread['id']))

                if self._thread is not None:
                    self._thread._update(thread)
                else:
                    self._thread = Thread(guild=self.guild, state=state, data=thread)

        self._interaction: Optional[MessageInteraction] = None

        # deprecated
        try:
            interaction = data['interaction']
        except KeyError:
            pass
        else:
            self._interaction = MessageInteraction(state=state, guild=self.guild, data=interaction)

        self.interaction_metadata: Optional[MessageInteractionMetadata] = None
        try:
            interaction_metadata = data['interaction_metadata']
        except KeyError:
            pass
        else:
            self.interaction_metadata = MessageInteractionMetadata(state=state, guild=self.guild, data=interaction_metadata)

        try:
            ref = data['message_reference']
        except KeyError:
            self.reference = None
        else:
            self.reference = ref = MessageReference.with_state(state, ref)
            try:
                resolved = data['referenced_message']
            except KeyError:
                pass