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 delete_after parameter to Webhook.send #414

Merged
merged 2 commits into from
Nov 8, 2021
Merged

Add delete_after parameter to Webhook.send #414

merged 2 commits into from
Nov 8, 2021

Conversation

krittick
Copy link
Contributor

@krittick krittick commented Nov 7, 2021

Summary

Adds a delete_after parameter in Webhook.send, to complement the similar change made in #180. This ensures that all messages sent with ctx.respond can have a delete_after parameter, rather than the current behavior of only allowing this for non-deferred responses.

Example usage:

from discord.commands import slash_command

@slash_command(name="deleteme", guild_ids=[...])
async def deleteme(ctx):
    await ctx.interaction.response.defer()
    # insert heavy calculations etc here
    await ctx.respond("Stuff is done, deleting in 5 seconds.", delete_after=5)

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, typehinting, examples, ...)

@BobDotCom
Copy link
Member

Webhooks were made to work both sync and async. Since this feature can't be easily made sync, I'd suggest not implementing it.

@krittick
Copy link
Contributor Author

krittick commented Nov 7, 2021

Webhooks were made to work both sync and async. Since this feature can't be easily made sync, I'd suggest not implementing it.

Webhook and SyncWebhook both inherit from BaseWebhook, so it makes sense to add async-specific methods in Webhook to extend async-specific functionality. Or is there some requirement to have all SyncWebhook methods match those of Webhook?

It's not a breaking change and provides easier management of automatically deleting messages for functionality that already has a similar mechanism (i.e. when invoked with ctx.respond). Presumably the bot developer also knows when they're using an asynchronous webhook or not. With synchronous webhooks, you'd typically want to leave handling delays like this up to the developer anyway, so I don't see a need to add the same feature to SyncWebhook.

@Lulalaby Lulalaby merged commit d90ffe2 into Pycord-Development:master Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants