dolfies / discord.py-self

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

Expected "Content-Type" header to be one of {'application/json'}. #623

Closed VTMGR closed 6 months ago

VTMGR commented 7 months ago

Summary

Accepting friend requests is broken.

Reproduction Steps

  1. Add this into the example discord.py-self bot.
    @bot.event
    async def on_relationship_add(after):
    if (after.type==discord.RelationshipType.incoming_request):
        await after.accept();
  2. Send a friend request to the user.

Code

import discord
bot = discord.Client()

@bot.event
async def on_relationship_add(after):
    if (after.type==discord.RelationshipType.incoming_request):
        await after.accept();

bot.run('token')

Expected Results

The friend request is accepted.

Actual Results

This error occurs and the request is not accepted.

[2023-12-04 03:20:51] [ERROR   ] discord.client: Ignoring exception in on_relationship_add
Traceback (most recent call last):
  File "C:\Users\####\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 507, in _run_event
    await coro(*args, **kwargs)
  File "E:\bot.py", line 27, in on_relationship_add
    await after.accept();
  File "C:\Users\####\AppData\Local\Programs\Python\Python310\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\####\AppData\Local\Programs\Python\Python310\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

Checklist

Additional Information

No response

VTMGR commented 7 months ago

Duplicate of Friendship Requests cannot be accepted #518

dolfies commented 6 months ago

This is indeed a duplicate, and is fixed in the alpha.