Skip to content

Compatibility changes for Discord.py#1572

Draft
whinis wants to merge 2 commits intospacebarchat:masterfrom
whinis:AddEmptyDecoratorToMostMessageFields
Draft

Compatibility changes for Discord.py#1572
whinis wants to merge 2 commits intospacebarchat:masterfrom
whinis:AddEmptyDecoratorToMostMessageFields

Conversation

@whinis
Copy link
Contributor

@whinis whinis commented Mar 5, 2026

Added the JsonRemoteEmpty to more fields in the message class

…ssage class. Hopefully shouldn't break anything.
@whinis whinis marked this pull request as draft March 5, 2026 23:57
@MathMan05
Copy link
Contributor

When I get a chance I'll review this change

@whinis
Copy link
Contributor Author

whinis commented Mar 6, 2026

Thats ok, I am using this as a draft to fix multiple issues with discord.py so going to try a few things first.

@whinis whinis force-pushed the AddEmptyDecoratorToMostMessageFields branch from 621c153 to d452006 Compare March 6, 2026 01:03
@e-lisa
Copy link

e-lisa commented Mar 6, 2026

Still breaking on member.flags

https://github.com/Rapptz/discord.py/blob/master/discord/member.py#L331

(sorry, i was running a patched version of discord.py to bypass this, but this will break for others)

Exception in thread Thread-1 (run_discord):
Traceback (most recent call last):
File "/usr/lib/python3.13/threading.py", line 1043, in _bootstrap_inner
self.run()
~~~~~~~~^^
File "/usr/lib/python3.13/threading.py", line 994, in run
self._target(*self._args, **self._kwargs)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/bin/catpuppetbridge", line 40, in run_discord
discordbot.run(discord_token)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
File "/usr/local/lib/catpuppetbridge/venv/lib/python3.13/site-packages/discord/client.py", line 929, in run
asyncio.run(runner())
~~~~~~~~~~~^^^^^^^^^^
File "/usr/lib/python3.13/asyncio/runners.py", line 195, in run
return runner.run(main)
~~~~~~~~~~^^^^^^
File "/usr/lib/python3.13/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/usr/lib/python3.13/asyncio/base_events.py", line 725, in run_until_complete
return future.result()
~~~~~~~~~~~~~^^
File "/usr/local/lib/catpuppetbridge/venv/lib/python3.13/site-packages/discord/client.py", line 918, in runner
await self.start(token, reconnect=reconnect)
File "/usr/local/lib/catpuppetbridge/venv/lib/python3.13/site-packages/discord/client.py", line 847, in start
await self.connect(reconnect=reconnect)
File "/usr/local/lib/catpuppetbridge/venv/lib/python3.13/site-packages/discord/client.py", line 727, in connect
await self.ws.poll_event()
File "/usr/local/lib/catpuppetbridge/venv/lib/python3.13/site-packages/discord/gateway.py", line 635, in poll_event
await self.received_message(msg.data)
File "/usr/local/lib/catpuppetbridge/venv/lib/python3.13/site-packages/discord/gateway.py", line 582, in received_message
func(data)
~~~~^^^^^^
File "/usr/local/lib/catpuppetbridge/venv/lib/python3.13/site-packages/discord/state.py", line 1322, in parse_guild_create
guild = self._get_create_guild(data)
File "/usr/local/lib/catpuppetbridge/venv/lib/python3.13/site-packages/discord/state.py", line 1263, in _get_create_guild
return self._add_guild_from_data(data)
~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/usr/local/lib/catpuppetbridge/venv/lib/python3.13/site-packages/discord/state.py", line 530, in _add_guild_from_data
guild = Guild(data=data, state=self)
File "/usr/local/lib/catpuppetbridge/venv/lib/python3.13/site-packages/discord/guild.py", line 473, in __init__
self._from_data(data)
~~~~~~~~~~~~~~~^^^^^^
File "/usr/local/lib/catpuppetbridge/venv/lib/python3.13/site-packages/discord/guild.py", line 654, in _from_data
member = Member(data=mdata, guild=self, state=self._state)  # type: ignore # Members will have the 'user' key in this scenario
File "/usr/local/lib/catpuppetbridge/venv/lib/python3.13/site-packages/discord/member.py", line 329, in __init__
self._flags: int = data['flags']
~~~~^^^^^^^^^
KeyError: 'flags'

Copy link
Contributor

@MathMan05 MathMan05 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://docs.discord.food/resources/message#message-object
Please use the documentation to replicate the structure of the message object. I could be wrong in some of these spots.

// the position field. Needs to be looked into more
// TODO: Look into when this can be undefined during CHANNEL_UPDATE
if (this.position === undefined) {
this.position = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please do this in the object instead

@Column({ nullable: true })
@RelationId((message: Message) => message.channel)
@Index()
@JsonRemoveEmpty
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not optional


@Column({ nullable: true })
@RelationId((message: Message) => message.thread)
@JsonRemoveEmpty
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a property that should end up in the result


@Column({ nullable: true })
@RelationId((message: Message) => message.guild)
@JsonRemoveEmpty
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a property of the message object

@ManyToOne(() => Guild, {
onDelete: "CASCADE",
})
@JsonRemoveEmpty
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a property of the message object

edited_timestamp?: Date;

@Column({ nullable: true })
@JsonRemoveEmpty
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why it's marked as such, but it's not optional


@Column({ nullable: true })
@JsonRemoveEmpty
mention_everyone?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why it's marked as such, but it's not optional

nonce?: string;

@Column({ nullable: true, type: Date })
@JsonRemoveEmpty
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not a part of the message, and you can see the type includes null


@Column({ nullable: true })
@JsonRemoveEmpty
username?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not matter as it's just being used then defaulted if nullish

username?: string;

@Column({ nullable: true })
@JsonRemoveEmpty
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not matter as it's just being used then defaulted if nullish

@whinis whinis changed the title Add Decorators to More Fields Compatibility changes for Discord.py Mar 6, 2026
@e-lisa
Copy link

e-lisa commented Mar 7, 2026

replied_to = await message.channel.fetch_message(message.reference.message_id)

EXPECTED BEHAVIOR:
When getting the author of replied to messages, there should be a message.author (in the example above, replied_to.author on fetched messages from the channel.

CURRENT BEHAVIOR:
message.author is missing when fetched from await message.channel.fetch_message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants