From a6ac12834007c47854846d254de39caf61b33d64 Mon Sep 17 00:00:00 2001 From: anima Date: Tue, 30 Nov 2021 23:20:05 +0100 Subject: [PATCH] add typing until runing --- main.py | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/main.py b/main.py index ed48f1e..9426f6a 100644 --- a/main.py +++ b/main.py @@ -47,25 +47,31 @@ async def on_ready(): for guild in bot.guilds: log.info(f'Connect to Server {guild.name} (id: {guild.id})') +@bot.event +async def on_reaction_add(reac, usr): + print(reac) + print(usr) + ### Commands @bot.command(name='hello', help='Say hello!') async def say_hello(ctx): - log.info('Start say_hello function') - await ctx.message.add_reaction('🤔') - await ctx.send(f'Hello, <@{ctx.author.id}>!') - print(ctx.guild) - print(ctx.message.content) - print(ctx.message) - print(ctx.author) - await aio.sleep(random.randint(1,5)) - await ctx.message.remove_reaction('🤔', bot.user) - if random.randint(1,100) < 10: - log.error('say_hello function was failed') - await ctx.message.add_reaction('❌') - else: - log.info('Run say_hello successfully') - await ctx.message.add_reaction('✅') - await aio.sleep(10) + async with ctx.typing(): + log.info('Start say_hello function') + await ctx.message.add_reaction('🤔') + await ctx.send(f'Hello, <@{ctx.author.id}>!') + print(ctx.guild) + print(ctx.message.content) + print(ctx.message) + print(ctx.author) + await aio.sleep(random.randint(1,5)) + await ctx.message.remove_reaction('🤔', bot.user) + if random.randint(1,100) < 10: + log.error('say_hello function was failed') + await ctx.message.add_reaction('❌') + else: + log.info('Run say_hello successfully') + await ctx.message.add_reaction('✅') + await aio.sleep(10) await ctx.message.delete() #keep_alive()