dolfies / discord.py-self

A fork of the popular discord.py for user accounts.
https://discordpy-self.rtfd.io/en/latest/
MIT License
703 stars 162 forks source link

MessageToDict TypeError on changing presence #740

Open hydroxideee opened 3 weeks ago

hydroxideee commented 3 weeks ago

Summary

When changing presence to idle TypeError is raised

Reproduction Steps

Call Client.change_presence with status set to idle and afk=True

Code

afk = selfclient.is_afk()
if not afk:
    await selfclient.change_presence(status=selfcord.Status.idle,
                                     afk=True,
                                     idle_since=selfbot_start_datetime,
                                     edit_settings=False)

Expected Results

Presence should change with no error and push notifications should start to be received.

Actual Results

Traceback (most recent call last):
  File "/home/container/main.py", line 557, in keep_afk
    await selfclient.change_presence(status=selfcord.Status.idle,
  File "/home/container/.local/lib/python3.11/site-packages/selfcord/client.py", line 1797, in change_presence
    await self.settings.edit(**payload)
  File "/home/container/.local/lib/python3.11/site-packages/selfcord/settings.py", line 1108, in edit
    existing = self.to_dict()
               ^^^^^^^^^^^^^^
  File "/home/container/.local/lib/python3.11/site-packages/selfcord/settings.py", line 154, in to_dict
    return MessageToDict(
           ^^^^^^^^^^^^^^
TypeError: MessageToDict() got an unexpected keyword argument 'always_print_fields_with_no_presence'

Presence appears to change to idle even with the error being raised, but no push notifications are received this way.

System Information

- Python v3.11.10-final
- selfcord.py v2.1.0-alpha
    - selfcord.py metadata: v2.1.0a4415+gbffa263e
- aiohttp v3.9.1
- system info: Linux 6.1.0-18-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.76-1 (2024-02-01)

Checklist

Additional Information

Might be similar to #729 but downgrading the protobuf library to the 4.25.4 or lower did not fix the issue

Ulysse2211 commented 2 weeks ago

Confirming I'm having this issue too: This code (from the documentation):

async def on_ready():    
    game = discord.Game("with the Python")

throws this error:

2024-10-10 09:27:15 ERROR    discord.client Ignoring exception in on_ready
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/dist-packages/discord/client.py", line 507, in _run_event
    await coro(*args, **kwargs)
  File "/workspace/selfbot-unocorp/selfbot.py", line 223, in on_ready
    await client.change_presence(activity=game)
  File "/usr/local/lib/python3.12/dist-packages/discord/client.py", line 1567, in change_presence
    await self.settings.edit(**payload)
  File "/usr/local/lib/python3.12/dist-packages/discord/settings.py", line 1100, in edit
    existing = self.to_dict()
               ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/discord/settings.py", line 146, in to_dict
    return MessageToDict(
           ^^^^^^^^^^^^^^
TypeError: MessageToDict() got an unexpected keyword argument 'including_default_value_fields'

i'm gonna try to downgrade protobuf to see if it works. I'm letting you know.

Ulysse2211 commented 2 weeks ago

@hydroxideee, downgrading to protobuf 4.25.0 solved the issue form me. You could try to do the same, I did it in a venv, but didn't try protobuf version 4.25.4.