> Discover all available pages from the documentation index: https://mastra.zisheng.pro/ja/llms.txt # Discord Discord channel を使用すると、Mastra Agent は Discord のインタラクションと Bot メッセージを受信できます。Mastra は Agent の接続と Webhook ルートを処理します。Discord アプリケーションの設定、Bot の権限、Gateway の動作については、Chat SDK の Discord アダプターのドキュメントを参照してください。 ## アダプターのインストール Chat SDK から Discord アダプターをインストールします。 **npm**: ```bash npm install @chat-adapter/discord ``` **pnpm**: ```bash pnpm add @chat-adapter/discord ``` **Yarn**: ```bash yarn add @chat-adapter/discord ``` **Bun**: ```bash bun add @chat-adapter/discord ``` ## Agent の設定 Agent の `channels.adapters` オブジェクトに `createDiscordAdapter()` を追加します。 ```typescript import { Agent } from '@mastra/core/agent' import { createDiscordAdapter } from '@chat-adapter/discord' export const discordAgent = new Agent({ id: 'discord-agent', name: 'Discord Agent', instructions: 'Answer questions and help with tasks in Discord.', model: 'openai/gpt-5.6-sol', channels: { adapters: { discord: createDiscordAdapter(), }, }, }) ``` Mastra インスタンスに Agent を登録します。 ```typescript import { Mastra } from '@mastra/core' import { discordAgent } from './agents/discord-agent' export const mastra = new Mastra({ agents: { discordAgent }, }) ``` ## アダプターの設定 アプリケーションの作成、Bot トークン、インタラクションエンドポイント、権限、Gateway の動作など、Discord 固有の設定については、[Chat SDK Discord アダプターのドキュメント](https://chat-sdk.dev/adapters/official/discord)に従ってください。 アダプターは、次のような環境変数から Discord の認証情報を読み取ります。 ```bash DISCORD_BOT_TOKEN=your-discord-bot-token DISCORD_PUBLIC_KEY=your-discord-application-public-key DISCORD_APPLICATION_ID=your-discord-application-id ``` ## Webhook URL Mastra は、Agent ID とアダプターキーから Discord の Webhook ルートを生成します。 ```text /api/agents/discord-agent/channels/discord/webhook ``` 公開されている Mastra サーバーの URL をベース URL として使用します。 ```text https://your-app.example.com/api/agents/discord-agent/channels/discord/webhook ``` Discord アダプターのドキュメントでインタラクションエンドポイントまたは Webhook URL が求められる箇所には、この URL を使用します。Discord の通常メッセージイベントでは、生成された Webhook ルートとは別に Gateway の設定が必要な場合があります。その場合は Chat SDK アダプターのドキュメントに従ってください。 ## 関連情報 - [Channels の概要](https://mastra.zisheng.pro/ja/docs/capabilities/channels/overview) - [その他](https://mastra.zisheng.pro/ja/docs/capabilities/channels/other-adapters)