dolfies / discord.py-self

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

Unable to accept friend requests #527

Closed WifiRouterYT closed 1 year ago

WifiRouterYT commented 1 year ago

Summary

As the title states, I'm unable to accept friend requests programatically.

Reproduction Steps

  1. Add the following code to your main client class:
    async def on_relationship_add(self, relationship):
        if relationship.type == discord.RelationshipType.incoming_request:
            await relationship.accept()
  2. Send a friend request to your bot
  3. Receive a Bad Request (http code 400) in console.

Code

async def on_relationship_add(self, relationship):
    if relationship.type == discord.RelationshipType.incoming_request:
        await relationship.accept()

Expected Results

The friend request is automatically accepted.

Actual Results

2023-06-25 12:46:03 ERROR    discord.client Ignoring exception in on_relationship_add
Traceback (most recent call last):
  File "C:\Users\ivanz\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 507, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\ivanz\Desktop\telnet server\bot.py", line 13, in on_relationship_add
    await relationship.accept()
  File "C:\Users\ivanz\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\relationship.py", line 298, in accept
    await self._state.http.add_relationship(self.user.id, action=RelationshipAction.accept_request)
  File "C:\Users\ivanz\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\http.py", line 838, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In miscallenous: Expected "Content-Type" header to be one of {'application/json'}.

System Information

- Python v3.11.4-final
- discord.py-self v2.0.0-final
- aiohttp v3.8.3
- system info: Windows 10 10.0.22621

Checklist

Additional Information

No response

dolfies commented 1 year ago

Should be fixed now

WifiRouterYT commented 1 year ago

the error shows up rarely now, but it still does not accept friend requests. ive tried a pip upgrade but no luck.

belkarx commented 1 year ago

I am having this issue with send_friend_request()

WifiRouterYT commented 10 months ago

coming back to this, the exact same issue still occurs with the exact same code above edit: works fine on development version