dolfies / discord.py-self

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

Can't accept incoming friend request #414

Closed Barabazs closed 1 year ago

Barabazs commented 1 year ago

Summary

Accepting a friend request results in an error.

Reproduction Steps

I have an event subscriber for incoming friend requests and it should automatically accept these requests. See code below.

Code

async def on_relationship_add(self, relationship):
    """Event subscriber for when a relationship is added"""
    if relationship.type == discord.RelationshipType.incoming_request:
        await relationship.accept()

Expected Results

The friend request should be accepted.

Actual Results

Traceback (most recent call last):
  File "bot/venv/lib/python3.8/site-packages/discord/client.py", line 301, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 43, in on_relationship_add
    await relationship.accept()
  File "bot/venv/lib/python3.8/site-packages/discord/relationship.py", line 87, in accept
    await self._state.http.add_relationship(self.user.id, action=RelationshipAction.accept_request)
  File "bot/venv/lib/python3.8/site-packages/discord/http.py", line 302, in request
    raise HTTPException(r, data)
discord.errors.HTTPException: 400 Bad Request (error code: 0)

System Information

Checklist

Additional Information

I have seen this behaviour on v1.9.2 and the latest v2.0.0a (main branch).

ChineseRansomware commented 1 year ago

Could not replicate, userbot added account instantly on receiving a friendship request. Your code works. Consider that you might have a friend limit on an account or another factor not allowing adding a new friend. System Information

Attaching code used to test

import discord
TOKEN = "huh?"

class RelationshipTest(discord.Client):
    async def on_relationship_add(self, relationship):
        """Event subscriber for when a relationship is added"""
        if relationship.type == discord.RelationshipType.incoming_request:
            await relationship.accept()

c = RelationshipTest()
c.run(TOKEN)
dolfies commented 1 year ago

Sorry I ignored this issue. What you're seeing here is a captcha, update to the alpha to be able to handle them.