#Simulating typing in DMs

1 messages · Page 1 of 1 (latest)

wet junco
#

So I'm trying to simulate a user typing in DMs by making the bot type in a channel at the same time.

This is for a ModMail feature. According to the docs, an example would be:

    async with channel.typing():
        # simulate something heavy
        await asyncio.sleep(10)

    await channel.send('done!')

Now, as this occurs in a on_raw_typing listener, is there a way to synchronize the duration of the user typing in DMs with the bot? As in, if the user types in DMs for 10 seconds, the bot 'types' in a channel for the same duration, 10 seconds.

merry wyvern
#

X is typing... Isn't indicative of how long the user actually spent typing.

hollow leaf
#

It's not 100% accurate, but it sounds like you want to just forward typing events from DMs to the modmail channel through something like this:

@<decorator>
async def on_raw_typing(event: disnake.RawTypingEvent):
    if not event.guild_id:  # in DM
        channel = ...  # get modmail channel for event.user_id
        await channel.trigger_typing()
#

trigger_typing sends a one-time typing event, while the typing context manager from the example would repeatedly send them until the inner task finishes

#

but as DLCHAMP mentioned, a single typing event will show in the UI for ~10 seconds, even if you stop typing after eg. 2 seconds

wet junco
#

Gotcha, thank you everyone