Clawdbot Discord Skill - Discord APIを統合したメッセージ自動化
Clawdbot向けDiscord Skillを利用して、メッセージ送信、リアクション、スレッド管理、サーバー運用の自動化を実現する方法を解説します。
Clawdbotの公式Skillとして提供されているDiscord Skillは、Discord REST APIを利用したメッセージ送信、リアクション管理、スレッド操作、サーバー運用の自動化を可能にするツールである。本記事では、Discord Skillの技術仕様、主要機能、実装例、およびセキュリティ考慮事項について解説する。
概要
Discord Skillは、Clawdbot(AI駆動のCLIエージェント)からDiscord APIを制御するためのインターフェースを提供する。メッセージの送信・編集・削除、リアクション追加、投票(Poll)作成、スレッド管理、絵文字・スタンプのアップロード、メンバー情報取得など、Discord Bot開発で必要となる主要機能をカバーしている。
技術的には、Clawdbot内部のmessageツール(Discord用プラグイン)経由でDiscord REST APIへリクエストを送信し、BotトークンによるOAuth認証を使用する。チャンネル管理やモデレーション機能は、デフォルトで無効化されており、明示的な設定により有効化する必要がある。
技術的仕様
システム要件
- Clawdbot: バージョン不明(公式ドキュメントに記載なし)
- Discord Bot Token: Discord Developer Portalで発行(OAuth2スコープ:
bot, Permissions: 必要な権限を事前設定) - 環境変数: BotトークンをClawdbot設定に登録
- 依存関係: なし(Clawdbot組み込みツール)
インストール方法
Discord Skillは組み込みSkillのため、追加インストール不要。Botトークンの設定のみ必要となる。
# Discord Bot Token設定例(環境変数またはClawdbot設定ファイル)
export DISCORD_BOT_TOKEN="YOUR_BOT_TOKEN_HERE"
Discord Developer Portalでの事前準備:
- https://discord.com/developers/applications でアプリケーション作成
- Bot設定からトークン取得
- OAuth2 URL GeneratorでBotをサーバーに招待
- 必要な権限を付与(例: Send Messages, Manage Messages, Add Reactions等)
APIエンドポイント
Discord Skillは以下のDiscord REST API v10エンドポイントを利用:
/channels/{channelId}/messages(メッセージ送受信)/channels/{channelId}/messages/{messageId}/reactions(リアクション)/channels/{channelId}/threads(スレッド管理)/guilds/{guildId}/emojis(カスタム絵文字)/guilds/{guildId}/stickers(スタンプ)- その他(チャンネル管理、メンバー情報、イベント等)
アクセス制御
Discord Skillは、アクション単位でのゲーティング機能を提供する。デフォルトではメッセージ送信・リアクション・スレッド管理等が有効だが、以下の機能はデフォルトで無効:
- roles: ロール付与・削除(
discord.actions.roles: false) - channels: チャンネル・カテゴリの作成・編集・削除(
discord.actions.channels: false) - moderation: タイムアウト・キック・BAN(
discord.actions.moderation: false)
有効化には、Clawdbot設定ファイルで明示的にtrueを設定する必要がある。
主要機能
メッセージ送信
{
"action": "sendMessage",
"to": "channel:123456789012345678",
"content": "デプロイ完了: v1.2.3"
}
- メディア添付:
mediaUrlパラメータで画像・音声・動画を添付可能(file:///path/to/fileまたはhttps://...) - 返信:
replyToパラメータでメッセージIDを指定し、特定メッセージへ返信 - DM送信:
to: "user:987654321098765432"でダイレクトメッセージ送信
リアクション管理
{
"action": "react",
"channelId": "123456789012345678",
"messageId": "987654321098765432",
"emoji": "✅"
}
カスタム絵文字の場合:
{
"emoji": "<:emoji_name:1234567890>"
}
リアクションユーザー一覧取得:
{
"action": "reactions",
"channelId": "123456789012345678",
"messageId": "987654321098765432",
"limit": 100
}
投票(Poll)作成
{
"action": "poll",
"to": "channel:123456789012345678",
"question": "次のリリース日はいつがよい?",
"answers": ["2026-02-20", "2026-02-27", "2026-03-05"],
"allowMultiselect": false,
"durationHours": 24
}
- 期間:
durationHoursは最大768時間(32日間) - 複数選択:
allowMultiselect: trueで複数回答可能
スレッド管理
スレッド作成(メッセージから派生):
{
"action": "threadCreate",
"channelId": "123456789012345678",
"name": "Bug修正ディスカッション",
"messageId": "987654321098765432"
}
スレッド一覧取得:
{
"action": "threadList",
"guildId": "111222333444555666"
}
カスタム絵文字・スタンプアップロード
絵文字アップロード:
{
"action": "emojiUpload",
"guildId": "111222333444555666",
"name": "clawdbot_logo",
"mediaUrl": "file:///tmp/logo.png",
"roleIds": ["777888999000111222"]
}
- 制限: PNG/JPG/GIF、256KB以下
- 権限:
roleIds省略時は全メンバーが使用可能
スタンプアップロード:
{
"action": "stickerUpload",
"guildId": "111222333444555666",
"name": "celebration",
"description": "祝賀スタンプ",
"tags": "🎉",
"mediaUrl": "file:///tmp/sticker.png"
}
- 制限: PNG/APNG/Lottie JSON、512KB以下
実装例
例1: デプロイ完了通知の自動送信
#!/bin/bash
# deploy-notify.sh
VERSION="v1.3.0"
CHANNEL_ID="123456789012345678"
# デプロイ実行
./deploy.sh
# Discord通知
clawdbot run <<EOF
message action:send target:channel:${CHANNEL_ID} message:"デプロイ完了: ${VERSION}"
EOF
例2: エラーレポートへのリアクション追加
// error-reaction.js
const { exec } = require('child_process');
const channelId = '123456789012345678';
const messageId = '987654321098765432';
exec(`clawdbot run 'message action:react channelId:${channelId} messageId:${messageId} emoji:"⚠️"'`, (error, stdout, stderr) => {
if (error) {
console.error(`エラー: ${error.message}`);
return;
}
console.log('リアクション追加完了');
});
例3: 週次投票の自動作成
// weekly-poll.js
const channelId = '123456789012345678';
const pollData = {
action: 'poll',
to: `channel:${channelId}`,
question: '今週の優先タスクは?',
answers: ['機能A開発', '機能B開発', 'バグ修正', 'ドキュメント更新'],
allowMultiselect: true,
durationHours: 168, // 7日間
content: '投票をお願いします'
};
const command = `clawdbot run 'message ${Object.entries(pollData).map(([k, v]) => `${k}:"${v}"`).join(' ')}'`;
require('child_process').exec(command);
例4: メンバー情報取得とログ記録
#!/bin/bash
# member-audit.sh
GUILD_ID="111222333444555666"
USER_ID="333444555666777888"
# メンバー情報取得
INFO=$(clawdbot run "message action:member-info guildId:${GUILD_ID} userId:${USER_ID}")
# ログファイルに記録
echo "[$(date)] ${INFO}" >> audit.log
例5: メッセージ検索とアーカイブ
// search-archive.js
const { exec } = require('child_process');
const guildId = '111222333444555666';
const query = 'セキュリティアラート';
const searchCmd = `clawdbot run 'message action:search guildId:${guildId} content:"${query}" limit:50'`;
exec(searchCmd, (error, stdout, stderr) => {
if (error) {
console.error(`検索エラー: ${error.message}`);
return;
}
const results = JSON.parse(stdout);
console.log(`検索結果: ${results.length}件`);
// 結果をファイルに保存
require('fs').writeFileSync('archive.json', JSON.stringify(results, null, 2));
});
ユースケース
開発チーム向け
- CI/CD通知: GitHub ActionsやJenkinsからのビルド成功・失敗通知
- エラーアラート: 本番環境のエラーログをDiscordチャンネルに自動投稿
- コードレビュー: プルリクエスト作成時に専用スレッドを自動生成
プロジェクト管理
- タスク完了確認: 投票機能で優先順位決定
- 定期リマインダー: 毎週の進捗報告をスケジュール投稿
コミュニティ運用
- 新規メンバーウェルカム: 参加時に自動でDM送信
- イベント告知: カレンダー連携でイベント作成・通知
制限事項・セキュリティ考慮事項
API制限
- レート制限: Discord APIは以下のレート制限を適用(公式ドキュメントに記載)
- グローバル: 50リクエスト/秒
- エンドポイント別: 5-10リクエスト/秒
- ファイルサイズ: 絵文字256KB、スタンプ512KB、通常添付ファイル8MB(Nitroサーバーは100MB)
セキュリティ
- トークン保護: Botトークンは環境変数または暗号化設定ファイルに保存(ソースコードに記載禁止)
- 権限最小化: 必要最低限の権限のみ付与(例: メッセージ送信のみの場合は
Send Messagesのみ) - 監査ログ: モデレーション操作は監査ログに記録(Discord側の機能)
ベストプラクティス
- エラーハンドリング: APIエラー時の再試行ロジック実装推奨
- ログ記録: 送信メッセージの内容・時刻を記録(トラブルシューティング用)
- テスト環境: 本番サーバーではなく、テスト用サーバーで動作確認
参考リンク
- Discord Developer Portal: https://discord.com/developers/docs
- Discord API Reference: https://discord.com/developers/docs/reference
- Clawdbot公式サイト: https://clawdbot.com
- Discord Bot Best Practices: https://discord.com/developers/docs/topics/community-resources
本記事の情報は2026年2月15日時点のものです。Discord API仕様やClawdbotのアップデートにより、機能や制限事項が変更される可能性があります。最新情報は各公式サイトをご確認ください。
Related Articles
OpenClaw v2026.2.15 Released: Discord Components v2 and Nested Sub-Agents
OpenClaw releases v2026.2.15 one day after v2026.2.14, adding Discord interactive components, nested sub-agents with configurable depth, plugin hook enhancements, and continued security hardening.
OpenClaw Skills Ranking February 2026: Planning Skills and Security Suite Dominate Top 10
GitHub OpenClaw skills ranking shows awesome-openclaw-skills (16,139 stars), Manus-style planning implementation planning-with-files (14,000 stars), and Obsidian integration (9,998 stars) claiming top 3 positions.
OpenClaw v2026.2.17: Claude Sonnet 4.6 Support, 1M Context, Slack/Telegram Enhancements
OpenClaw releases major update with Claude Sonnet 4.6 and 1M context window support, Slack native streaming, Telegram inline button styles, iOS Share Extension, and critical security fixes (OC-09) among 100+ changes.
Popular Articles
Claude Code v2.1.93 Released - Deferred Permission Decisions, Flicker-Free Rendering, and More
Anthropic releases Claude Code v2.1.93 with deferred permission decisions for PreToolUse hooks, flicker-free rendering option, PermissionDenied hook, and named subagent typeahead support.
Claude Code v2.1.92 Released - forceRemoteSettingsRefresh, Bedrock Setup Wizard, and More
Anthropic releases Claude Code v2.1.92 with forceRemoteSettingsRefresh policy setting, AWS Bedrock setup wizard, /cost command improvements, and numerous bug fixes.
Claude Code v2.1.84 Release - PowerShell Tool Preview and Environment Configuration Enhancements
Claude Code v2.1.84 introduces PowerShell tool for Windows, new environment variable overrides for model selection, idle session handling improvements, and various stability fixes.
Latest Articles
Claude Code v2.1.93 Released - Deferred Permission Decisions, Flicker-Free Rendering, and More
Anthropic releases Claude Code v2.1.93 with deferred permission decisions for PreToolUse hooks, flicker-free rendering option, PermissionDenied hook, and named subagent typeahead support.
Claude Code v2.1.92 Released - forceRemoteSettingsRefresh, Bedrock Setup Wizard, and More
Anthropic releases Claude Code v2.1.92 with forceRemoteSettingsRefresh policy setting, AWS Bedrock setup wizard, /cost command improvements, and numerous bug fixes.
Claude Code v2.1.91 Released - MCP Tool Result Persistence and Improved Edit Tool
Claude Code v2.1.91 introduces MCP tool result persistence override, improved shell execution controls, and enhanced Edit tool efficiency.