question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ability to delete messages sent from a webhook a few days later.

See original GitHub issue

I want to delete all the messages I sent with DiscordWebhook but not in the same run as in your example:

from discord_webhook import DiscordWebhook
from time import sleep

webhook = DiscordWebhook(url='your webhook url', content='Webhook Content')
sent_webhook = webhook.execute()
sleep(10)
webhook.delete(sent_webhook)

I would like something like:

from discord_webhook import DiscordWebhook

webhook = DiscordWebhook(url='your webhook url', content='Webhook Content')
sent_webhook = webhook.execute()
sent_webhook .save('sent_webhook .swh')

And then a few days later, the following imaginary code is executed:

from discord_webhook import DiscordWebhook

webhook, sent_webhook = DiscordWebhook(file='sent_webhook.swh')
webhook.delete(sent_webhook)

Is it possible?

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
lovvskillzcommented, Nov 15, 2022

@beuaaa I’m currently rewriting the code to allow for something like this. In the end, this is how it will be possible:

webhook = DiscordWebhook(url="url")
webhook.execute()
print(webhook.id)

# ... after some period of time

webhook = DiscordWebhook(url="url", id="webhook id")
response = webhook.delete()

So you’ll need to save the returned webhook id which will be available in the new webhook.id property.

1reaction
kshubham506commented, Nov 13, 2022

Thanks a lot @kshubham506 . I think you did the work with your fork so I will use your fork while this new feature is added in the original repo. With your fork how do you get the id of the sent message?

@lovvskillz I hope this change will be merged into this repo. Do you think there is a chance to merge this new feature? If yes, when?

HI @beuaaa , I use redis to store the sent message ids, ( i don’t need the ids’ indefinitely so redis pretty much solves all my use cases)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it possible to delete message sent out by bot made from ...
With the chat.delete method you normally can delete your own messages. However, your bot will not be able to delete your messages, ...
Read more >
How to delete webhook message? : r/MicrosoftTeams - Reddit
Hi, I use webhook and powershell to send message to MS Teams channel but I need sometimes to delete the message and even...
Read more >
chat.delete method - Slack API
This method deletes a message from a conversation. When used with a user token, this method may only delete messages that user themselves...
Read more >
Delete Webhooks - Box Developer Documentation
Select the webhook you want to delete by clicking on its ID. Click the Delete button. Confirm the action by clicking Delete under...
Read more >
Delete Message with the Twilio API - Pipedream
Delete a message record from your account. ... Pipedream makes it easy to connect APIs for Twilio and 1000+ other apps ... HTTP...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found