Answer the question
In order to leave comments, you need to log in
Why does client.get_channel() return None?
client = discord.Client()
async def my_background_task():
await client.wait_until_ready()
counter = 0
channel = client.get_channel(id)
print(channel)
while not client.is_closed():
counter += 1
await channel.send(counter)
await asyncio.sleep(60) # task runs every 60 seconds
@client.event
async def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
client.loop.create_task(my_background_task())
client.run('token', bot=False)
Answer the question
In order to leave comments, you need to log in
In the code, everything seems to be correct. Here is the code for the recipient of the channel by ID.
channel = client.get_channel(id)
Perhaps you entered the wrong channel ID that your bot is trying to receive. If you are sure that you entered the correct id, then I can’t help you with anything.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question