Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- # Filename: discord_webhook.py
- # Version: 1.0.0
- # Author: Jeoi Reqi
- """
- Description:
- - This script demonstrates how to send a message to a Discord webhook using Python's requests module.
- Requirements:
- - Python 3.x
- - requests module
- Usage:
- - Replace 'https://discord.com/api/webhooks/...' with your actual Discord webhook URL.
- - Run the script to send a test message to your Discord channel.
- Additional Notes:
- - Discord webhooks allow external services to send messages to Discord channels.
- - Ensure your webhook URL is correct and formatted properly.
- """
- import requests
- # Your webhook URL
- webhook_url = 'https://discord.com/api/webhooks/...'
- print(f"Sending To: {webhook_url}\nClick the link above to see the full webhook object.")
- # Message content
- message = {
- "content": "Hello,\nThis is a test message from my webhook!\n...\nTest complete!"
- }
- # Send the message
- response = requests.post(webhook_url, json=message)
- # Check the response status
- if response.status_code == 204:
- print('\nMessage sent successfully!')
- else:
- print('Failed to send message', response.status_code)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement