Fix timeout for ephemeral paginators and hybrid commands#1751
Fix timeout for ephemeral paginators and hybrid commands#1751AutonomousCat wants to merge 2 commits intointeractions-py:unstablefrom
Conversation
| repr=False, | ||
| ) | ||
| """The paginator that this timeout is associated with.""" | ||
| edit: Callable[..., Coroutine] = attrs.field(repr=False, default=None) |
There was a problem hiding this comment.
Any reason to pass edit to Timeout instead of, say, ctx? At least that way you can forgo the if-else chain added in send() below to determine the right edit() by just using ctx.edit() regardless of command type, as have been done by the _on_button() callback. (Alternatively, add ctx to Paginator attributes instead of Timeout, then use self.paginator.ctx.edit().)
There was a problem hiding this comment.
@mifuyutsuki HybridContext requires message. Storing ctx was the first thing I tried, but when testing, HybridContext types would error out since the message param was missing.
There was a problem hiding this comment.
I'm trying to figure out why HybridContext needs the message parameter in the first place.
There was a problem hiding this comment.
This is likely because said context was made before SlashContext had a default for message. It appears when a default was added, HybridContext was missed.
Pull Request Type
Description
While I was writing a command that uses ephemeral paginators, I noticed the timeout resulted in a 404 NotFound. While looking for ways to resolve this, I noticed that HybridContext required a
messageobject in it'sedit()function, so I used_prefixed_ctxto determine HybridContext. Probably not the best way to handle this, but I did what I could.Changes
editfield toTimeoutclass to store the message edit coroutinesend()andreply()to use the appropriate edit method based on command typeTest Scenarios
I tested with ephemeral, non-ephemeral, send, reply, slash, hybrid, and prefixed. Now works in all cases without errors.
Python Compatibility
3.10.x3.11.xChecklist
pre-commitcode linter over all edited files