From 2a39686d43c8fc9557eeb11f1b93fbd7c3ec1826 Mon Sep 17 00:00:00 2001 From: Michael Yang Date: Fri, 4 Aug 2023 00:31:17 -0700 Subject: [PATCH] use reaction to communicate thinking state --- discollama.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/discollama.py b/discollama.py index ccfee20..a92fb4f 100644 --- a/discollama.py +++ b/discollama.py @@ -76,7 +76,8 @@ async def on_message(message): await message.channel.send('What can I do for you?', reference=message) return - response = await message.reply(':thinking:') + await message.add_reaction('🤔') + response = None # TODO: discord has a 2000 character limit, so we need to split the response buffer = '' @@ -92,7 +93,12 @@ async def on_message(message): if len(buffer) >= args.buffer_size: # buffer the edit so as to not call Discord API too often response_content += buffer - await response.edit(content=response_content + '...') + + if response: + await response.edit(content=response_content + '...') + else: + response = await message.reply(response_content) + await message.remove_reaction('🤔', client.user) buffer = ''