Skip to content
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 delay kwarg to message.delete() #2094

Closed
wants to merge 2 commits into from
Closed

Conversation

Vexs
Copy link
Contributor

@Vexs Vexs commented Apr 17, 2019

Summary

This PR adds a delay kwarg to message.delete that delays the deletion of a message while yielding back to the event loop. This is the same behavior used in delete_after kwargs, but for more generic usage. It also refactors existing delete_after behaviors to use the new kwarg.

Checklist

  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, ...)

Refactor delete_after kwargs to use new delay kwarg
Copy link
Owner

@Rapptz Rapptz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I'm too keen on the wording. The kwarg is delete_after not delete_delay but await x.delete(after=30.0) is different from after used elsewhere in the lib (i.e. a callback). I suppose the naming itself is fine.

@@ -563,7 +563,7 @@ def system_content(self):
else:
return '{0.author.name} started a call \N{EM DASH} Join the call.'.format(self)

async def delete(self):
async def delete(self, delay=None):
Copy link
Owner

@Rapptz Rapptz Apr 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
async def delete(self, delay=None):
async def delete(self, *, delay=None):

This needs to be a keyword only argument. await m.delete(10.0) is bad readability and could be ambiguous in the future.

Also, it needs an addition in the docstring.

.. versionadded:: 1.1.0
   The ``delay`` keyword-only parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh bugger I completely forgot. Yes, this should be that.

@Rapptz Rapptz added this to the v1.1 milestone Apr 18, 2019
@Rapptz Rapptz added the merged Tag to mark pull requests as rebased or merged label Apr 18, 2019
@Rapptz Rapptz closed this Apr 18, 2019
@Vexs Vexs deleted the delete_delay branch April 19, 2019 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged Tag to mark pull requests as rebased or merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants