> ## Documentation Index
> Fetch the complete documentation index at: https://cndoc-langchain.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Discord 集成

> 使用 LangChain Python 与 Discord 文档加载器集成。

> [Discord](https://discord.com/) 是一个语音通话和即时通讯社交平台。用户可以通过语音通话、视频通话、文字消息、媒体和文件在私人聊天或称为“服务器”的社区中进行交流。服务器是持久聊天室和语音频道的集合，可以通过邀请链接访问。

请按照以下步骤下载您的 `Discord` 数据：

1. 前往您的 **用户设置**
2. 然后前往 **隐私与安全**
3. 前往 **请求我的所有数据** 并点击 **请求数据** 按钮

您可能需要等待30天才能收到数据。您将在注册 Discord 时使用的邮箱地址收到一封电子邮件。该邮件中将包含一个下载按钮，通过它您可以下载您的个人 Discord 数据。

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
import os

import pandas as pd
```

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
path = input('请输入 Discord "messages" 文件夹内容的路径： ')
li = []
for f in os.listdir(path):
    expected_csv_path = os.path.join(path, f, "messages.csv")
    csv_exists = os.path.isfile(expected_csv_path)
    if csv_exists:
        df = pd.read_csv(expected_csv_path, index_col=None, header=0)
        li.append(df)

df = pd.concat(li, axis=0, ignore_index=True, sort=False)
```

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
from langchain_community.document_loaders.discord import DiscordChatLoader
```

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
loader = DiscordChatLoader(df, user_id_col="ID")
print(loader.load())
```

***

<div className="source-links">
  <Callout icon="terminal-2">
    [将这些文档连接](/use-these-docs)到 Claude、VSCode 等，通过 MCP 获取实时答案。
  </Callout>

  <Callout icon="edit">
    [在 GitHub 上编辑此页面](https://github.com/langchain-ai/docs/edit/main/src/oss/python/integrations/document_loaders/discord.mdx) 或 [提交问题](https://github.com/langchain-ai/docs/issues/new/choose)。
  </Callout>
</div>
