Skip to content

Commit bd37c67

Browse files
committed
add delete_after parameter to Webhook.send
1 parent 7e4ce97 commit bd37c67

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

discord/webhook/async_.py

Lines changed: 10 additions & 1 deletion
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,7 +1378,9 @@ async def send(
13771378
The thread to send this webhook to.
13781379
13791380
.. versionadded:: 2.0
1380-
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.
13811384
Raises
13821385
--------
13831386
HTTPException
@@ -1459,6 +1462,12 @@ async def send(
14591462
message_id = None if msg is None else msg.id
14601463
self._state.store_view(view, message_id)
14611464

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

14641473
async def fetch_message(

0 commit comments

Comments
 (0)