add typing until runing

This commit is contained in:
2021-11-30 23:20:05 +01:00
parent 59c5df71af
commit a6ac128340

38
main.py
View File

@@ -47,25 +47,31 @@ async def on_ready():
for guild in bot.guilds: for guild in bot.guilds:
log.info(f'Connect to Server {guild.name} (id: {guild.id})') 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 ### Commands
@bot.command(name='hello', help='Say hello!') @bot.command(name='hello', help='Say hello!')
async def say_hello(ctx): async def say_hello(ctx):
log.info('Start say_hello function') async with ctx.typing():
await ctx.message.add_reaction('🤔') log.info('Start say_hello function')
await ctx.send(f'Hello, <@{ctx.author.id}>!') await ctx.message.add_reaction('🤔')
print(ctx.guild) await ctx.send(f'Hello, <@{ctx.author.id}>!')
print(ctx.message.content) print(ctx.guild)
print(ctx.message) print(ctx.message.content)
print(ctx.author) print(ctx.message)
await aio.sleep(random.randint(1,5)) print(ctx.author)
await ctx.message.remove_reaction('🤔', bot.user) await aio.sleep(random.randint(1,5))
if random.randint(1,100) < 10: await ctx.message.remove_reaction('🤔', bot.user)
log.error('say_hello function was failed') if random.randint(1,100) < 10:
await ctx.message.add_reaction('') log.error('say_hello function was failed')
else: await ctx.message.add_reaction('')
log.info('Run say_hello successfully') else:
await ctx.message.add_reaction('') log.info('Run say_hello successfully')
await aio.sleep(10) await ctx.message.add_reaction('')
await aio.sleep(10)
await ctx.message.delete() await ctx.message.delete()
#keep_alive() #keep_alive()