-
-
Notifications
You must be signed in to change notification settings - Fork 469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a native timeout for modal.py #1434
Conversation
I seem to be getting a RuntimeWarning when the timeout task exists: c:\users\nexus\pycharmprojects\pycord\discord\ui\modal.py:103: RuntimeWarning: coroutine 'TestModal.on_timeout' was never awaited
self.loop.create_task(self.on_timeout(), name=f"discord-ui-view-timeout-{self.id}")
RuntimeWarning: Enable tracemalloc to get the object allocation traceback I don't get this with the |
I cant fork your fork since i already have a fork of pycord. I cant write to your fork unfortunaly. change line 49 to self.timeout: float = timeout and line 103 to:
This should do the trick |
We should also make sure to call Modal.stop() on remove |
I’ll make the changes when I get home tomorrow 👍 |
Okay so with ecd8d60, the errors are no-longer present. |
I retract my previous comment, I think I'm just being a little bit dense, I'm gonna try with some different timeouts. If I am just being dense then this PR is ready to go. |
Can confirm that this now works and has been tested. No more errors in console, and debugging seems to match up with expected results. I'm gonna open this PR for review now :) |
👍 |
FYI, you could've just reviewed this PR and included suggestions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't tested, but the code portions look good
Summary
Modals do not currently have a native timeout (like Views do), meaning they never leave the modal store unless the form is submitted (resulting in them being in there forever when dismissed). This PR copies and slightly modifies the same behaviour and functions from discord.ui.View, and reflects it into discord.ui.Modal.
Checklist
type: ignore
comments were used, a comment is also left explaining why