対象チャンネルの歯車(チャンネルの編集)をクリック

「連携サービス」 -> 「ウェブフックを作成」をクリック

「ウェブフックURLをコピー」をクリック

PHPのソースに貼り付ける
$contents = '投稿したい内容';
$message = array(
'username' => 'Botです', // 投稿者名
'content' => $contents
);
// ↓コピーしたウェブフックURLを貼り付け
$webhook_url = 'https://discord.com/api/webhooks/xxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxxxx';
$options = array(
'http' => array(
'method' => 'POST',
'header' => 'Content-Type: application/json',
'content' => json_encode($message),
)
);
$resp = file_get_contents($webhook_url, false, stream_context_create($options));
実行すると投稿される
