Skip to content

Commit

Permalink
feat: wrap on_message with typing (Chainlit#991)
Browse files Browse the repository at this point in the history
Bot will show as typing while the run is running.
  • Loading branch information
dahifi authored May 13, 2024
1 parent 357f2cd commit 923da0d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions backend/chainlit/discord/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ async def process_discord_message(
await on_chat_start()

if on_message := config.code.on_message:
await on_message(msg)
async with channel.typing():
await on_message(msg)

if on_chat_end := config.code.on_chat_end:
await on_chat_end()
Expand Down Expand Up @@ -269,7 +270,7 @@ async def on_ready():
async def on_message(message: discord.Message):
if not client.user or message.author == client.user:
return

is_dm = isinstance(message.channel, discord.DMChannel)
if not client.user.mentioned_in(message) and not is_dm:
return
Expand Down

0 comments on commit 923da0d

Please sign in to comment.