问题
I'm currently trying to create a block user and send friend request command. However, I've hit a wall. It seems like the bot doesn't have permission or authorization to my account so it can't send friend requests or block users. How do I give it the permissions? Or maybe it isn't possible at all? Please let me know, I'd really appreciate it :>
My current code for the commands is below:
@client.command()
async def unfriend(ctx, *, user: discord.User):
await user.remove_friend()
await ctx.send('Friend has been removed')
@client.command()
async def sendrequest(ctx, *, user: discord.User):
await user.send_friend_request()
await ctx.author.send('Request sent')
@client.command()
async def block(ctx, *, user: discord.User):
await user.block()
await ctx.send(f'{member.mention} has been blocked by {ctx.author}')
@client.command()
async def unblock(ctx, *, user: discord.User):
await user.unblock()
await ctx.send(f"{member.mention} has been unblocked by {ctx.author}")
回答1:
Unfortunately, Discord does not allow bot users to add, block, or remove friends. You can only perform these actions through a normal Discord user, and if you were to do this through the program, that would be self botting, which is against Discord's Terms of Service.
Read about this send_friend_request() method here:
https://discordpy.readthedocs.io/en/latest/api.html?highlight=add%20friend#discord.User.send_friend_request
Discord's stance on self botting:
https://support.discord.com/hc/en-us/articles/115002192352-Automated-user-accounts-self-bots-
来源:https://stackoverflow.com/questions/63257902/discord-py-user-block-user-send-friend-request-error-403-forbidden-how-do-i-giv