[Python] Play with Discord's Webhook.

This time I would like to play with Discord's Webhook.

Get the URL of the webhook

① Open the channel settings

image.png Open "Edit Channel" on the right side of the channel name.

② Open the web hook

image.png Click Web Hook from the sidebar to open it.

③ Open the web hook

image.png Click "Create Webhook" in the upper right.

④ Create a webhook

image.png Leave the name and icon as they are. (To play later) Click the "Copy" button in the Webhook URL section. Then click the save button.

code

webhook.py


from discordwebhook import Discord #Loading Discord Webhook

discord = Discord(url="") #④ Paste the URL you copied when creating the Webhook
discord.post(
    content="Whebohook's sword, oh oh oh oh oh oh oh oh oh oh", #The contents of the message
    username="Webhook", #username
    avatar_url="https://pbs.twimg.com/profile_images/1201406146822557696/ewFFvnAa_200x200.jpg " #Icon URL
)

Run

When you run it, it looks like this! image.png

Recommended Posts

[Python] Play with Discord's Webhook.
Play with 2016-Python
Play RocketChat with API / Python
Play with the password mechanism of GitHub Webhook and Python
Play video with sound with python !! (tkinter / imageio)
Play with Prophet
FizzBuzz with Python3
Scraping with Python
Play audio files from Python with interrupts
Statistics with python
Scraping with Python
Play with PyTorch
Twilio with Python
Integrate with Python
Play Python async
AES256 with python
python starts with ()
I want to play with aws with python
with syntax (Python)
Bingo with python
Zundokokiyoshi with python
Play with CentOS 8
Play with Pyramid
Excel with Python
Play with Fathom
Microcomputer with Python
Cast with python
Python hand play (let's get started with AtCoder?)
[REAPER] How to play with Reascript in Python
Play with Google Spread Sheets in python (OAuth)
Play with Lambda layer (python) for about 5 minutes
Serial communication with Python
Django 1.11 started with Python3.6
Primality test with Python
Python with eclipse + PyDev.
Socket communication with Python
Data analysis with python 2
Scraping with Python (preparation)
Try scraping with Python.
Learning Python with ChemTHEATER 03
"Object-oriented" learning with python
Run Python with VBA
Handling yaml with python
Solve AtCoder 167 with python
Serial communication with python
[Python] Use JSON with Python
Learning Python with ChemTHEATER 05-1
Learn Python with ChemTHEATER
Run prepDE.py with python3
1.1 Getting Started with Python
Collecting tweets with Python
Binarization with OpenCV / Python
3. 3. AI programming with Python
Kernel Method with Python
Non-blocking with Python + uWSGI
Scraping with Python + PhantomJS
Posting tweets with python
Drive WebDriver with python
Play with Othello (Reversi)
Use mecab with Python3
[Python] Redirect with CGIHTTPServer