Skip to content

Commit d90ffe2

Browse files
authored
Merge pull request #414 from krittick/master
Add delete_after parameter to Webhook.send
2 parents 5bee7e3 + bba0479 commit d90ffe2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

discord/webhook/async_.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,6 +1312,7 @@ async def send(
13121312
view: View = MISSING,
13131313
thread: Snowflake = MISSING,
13141314
wait: bool = False,
1315+
delete_after: float = None,
13151316
) -> Optional[WebhookMessage]:
13161317
"""|coro|
13171318
@@ -1377,6 +1378,9 @@ async def send(
13771378
The thread to send this webhook to.
13781379
13791380
.. versionadded:: 2.0
1381+
delete_after: :class:`float`
1382+
If provided, the number of seconds to wait in the background
1383+
before deleting the message we just sent.
13801384
13811385
Raises
13821386
--------
@@ -1459,6 +1463,12 @@ async def send(
14591463
message_id = None if msg is None else msg.id
14601464
self._state.store_view(view, message_id)
14611465

1466+
if delete_after is not None:
1467+
async def delete():
1468+
await asyncio.sleep(delete_after)
1469+
await msg.delete()
1470+
asyncio.ensure_future(delete(), loop=self._state.loop)
1471+
14621472
return msg
14631473

14641474
async def fetch_message(

0 commit comments

Comments
 (0)