Discord.py send friend requests
Question:
Wondering how to send friend-requests with id.txt as infile.
My code looks like this but does not work
@client.event
async def on_ready():
with open("id.txt") as infile:
for line in infile:
id = int(line)
user = await client.get_user_info(id)
try:
time.sleep(.305)
await user.send.friend_request
except (discord.Forbidden, discord.HTTPException):
continue
Answers:
The correct coroutine is User.send_friend_request
, which you have to call.
from asyncio import sleep
@client.event
async def on_ready():
with open("id.txt") as infile:
for line in infile:
id = int(line)
user = await client.get_user_info(id)
try:
await sleep(.305)
await user.send_friend_request()
except (discord.Forbidden, discord.HTTPException):
continue
You should also use asyncio.sleep
to avoid unnecessary blocking.
Wondering how to send friend-requests with id.txt as infile.
My code looks like this but does not work
@client.event
async def on_ready():
with open("id.txt") as infile:
for line in infile:
id = int(line)
user = await client.get_user_info(id)
try:
time.sleep(.305)
await user.send.friend_request
except (discord.Forbidden, discord.HTTPException):
continue
The correct coroutine is User.send_friend_request
, which you have to call.
from asyncio import sleep
@client.event
async def on_ready():
with open("id.txt") as infile:
for line in infile:
id = int(line)
user = await client.get_user_info(id)
try:
await sleep(.305)
await user.send_friend_request()
except (discord.Forbidden, discord.HTTPException):
continue
You should also use asyncio.sleep
to avoid unnecessary blocking.