Answer the question
In order to leave comments, you need to log in
How to make the bot write to the channel on time?
So my code:
@tasks.loop(seconds=20)
async def timer_notify():
await client.wait_until_ready()
print('lol')
cur_time = localtime(time())
for user_id,counter in user_counter.items():
global msg
user = client.get_user(user_id)
msg = msg+' >> ' + user.name + ': ' + str(counter) + '\n'
msg = 'Статистика:\n'
Answer the question
In order to leave comments, you need to log in
You need to somehow find out the id of the desired channel. The easiest way: in the Discord client, RMB->Copy ID.
Further:
my_channel = client.get_channel(ID_нужного_канала)
await my_channel.send('Сообщение')
@tasks.loop(seconds=20)
async def timer_notify():
await client.wait_until_ready()
message.channel.send('lol')
cur_time = localtime(time())
for user_id,counter in user_counter.items():
global msg
user = client.get_user(user_id)
msg = msg+' >> ' + user.name + ': ' + str(counter) + '\n'
msg = 'Stats:\n'
PS find one difference, code works )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question