Rapptz / discord.py

An API wrapper for Discord written in Python.
http://discordpy.rtfd.org/en/latest
MIT License
14.89k stars 3.77k forks source link

Ability to see time took in wait_for() #6943

Closed ImNimboss closed 3 years ago

ImNimboss commented 3 years ago

Summary

The ability to see how long the user took to do x action in client.wait_for()

What is the feature request for?

The core library

The Problem

Example - I'm trying to make a typeracer command and would like to see how long the user took to answer, and I'm using wait_for() to detect the message. I can't find a good and asynchronous way to do that.

The Ideal Solution

Maybe wait_for() can return the message AND the time it took for the user to enter the message in a tuple/list if specified in function parameters?

The Current Solution

No good solutions, not that I'm aware of

Additional Context

No response

MrKomodoDragon commented 3 years ago

Couldn’t you use time.perf_counter?

lgaan commented 3 years ago

Logic for this would just be

first = await send("start")
last = await wait_for(...)
taken = last.created_at - first.created_at

This feels like a pretty niche request anyway.

ImNimboss commented 3 years ago

Couldn’t you use time.perf_counter?

Time is blocking tho

ImNimboss commented 3 years ago

Logic for this would just be

first = await send("start")
last = await wait_for(...)
taken = last.created_at - first.created_at

This feels like a pretty niche request anyway.

Thanks, was looking for something like this :)

LisABC commented 3 years ago

Couldn’t you use time.perf_counter?

Time is blocking tho

I mean time.perf_counter isn't blocking.