LoginSignup
2
2

More than 3 years have passed since last update.

【Python】DiscordのWebhookで遊ぶ。

Posted at

今回はDiscordのWebhookを使って遊んでみたいと思います。

WebhookのURLを取得する

①チャンネル設定を開く

image.png
チャンネル名の右側に出ている「チャンネルの編集」を開きます。

②ウェブフックを開く

image.png
サイドバーから「ウェブフック」をクリックし、開きます。

③ウェブフックを開く

image.png
右上の「ウェブフックを作成」をクリック。

④Webhookの作成

image.png
名前とアイコンはそのままにしてください。(後で遊ぶため)
ウェブフックURLの項目にある、「コピー」というボタンをクリック。
そして、保存ボタンをクリック。

コード

webhook.py
from discordwebhook import Discord # DiscordWebhookの読み込み

discord = Discord(url="") # ④Webhookの作成でコピーしたURLを貼りつける
discord.post(
    content="Whebohookのてすとおおおおおおおおおおおおおおおおおおおおおおおおおおお", # メッセージをの中身
    username="Webhook", # ユーザー名
    avatar_url="https://pbs.twimg.com/profile_images/1201406146822557696/ewFFvnAa_200x200.jpg" # アイコンのURL
)

実行

実行するとこんな感じになります!
image.png

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2