> For the complete documentation index, see [llms.txt](https://docs.convai.com/api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/other-integrations/discord/hosting-discord-bot-from-personal-server.md).

# 从个人服务器托管 Discord Bot

这里我们列出成功托管 Discord 机器人服务器的步骤，并更新所需细节，以便用户能够与所创建的角色有效交流。

{% hint style="info" %}
当前版本仅支持 Python 语言。我们正在努力加入对其他语言服务器的支持。如果您对此有任何疑问，请通过 <support@convai.com> 联系我们。
{% endhint %}

代码链接： [GitHub](https://github.com/Conv-AI/Convai_Discord_Integration)

步骤：

1. 访问上面提供的链接，并将仓库克隆到您要托管服务器的系统中。

   <figure><img src="/files/eacd9dc3308bee50bf2462ca69d82f33e6c56891" alt=""><figcaption></figcaption></figure>
2. 进入您的系统并打开 **终端**
3. 输入以下命令：

   ```bash
   $ git clone https://github.com/Conv-AI/Convai_Discord_Integration.git

   $ cd Convai_Discord_Integration

   $ cd python/
   ```
4. 我们现在已经进入了 **python** 文件夹，其中包含必要的代码。
5. 我们需要编辑 **.env** 文件，并用所需的凭据更新它。打开 .**env** 文件进行编辑并输入必要的详细信息。

   ```
   # Discord 为您的机器人生成的唯一令牌
   DISCORD_BOT_TOKEN=<我们在创建 Discord 机器人时于第 13 步收到的令牌>

   # 在 Convai 创建账户后收到的唯一 API 密钥。
   CONVAI_API_KEY=<您在 Convai 注册后获得的唯一密钥>

   # 使用 Convai 创建的新角色的角色 ID
   CONVAI_CHARACTER_ID=<我们在 Convai 网站创建角色时获得的用于识别该角色的唯一 ID>

   # 每次查询后从 Convai 服务器获取响应的 URL
   CHARACTER_GET_RESPONSE_URL=https://api.convai.com/character/getResponse

   # 启用语音回复以生成可在语音频道中播放的音频文件。当前仍在开发中
   ENABLE_VOICE_RESPONSE=False

   # 列出您希望机器人响应的所有频道，使用逗号 ',' 分隔
   # ALLOWED_CHANNELS=welcome,general,...
   ALLOWED_CHANNELS= <如果您希望机器人响应所有频道，请留空>
   ```
6. 有了这些，我们就可以启动服务器了，只需运行以下命令：

   ```bash
   $ python main.py
   ```
7. 现在机器人应该已经完美运行了。您应该会看到类似这样的日志，表示机器人已启动。

   <figure><img src="/files/74afe1d0ba97315868dd8d512384db91e8a9a5bb" alt=""><figcaption></figcaption></figure>

   注意：这里的 ConvaiBot 是我们给它起的名字。您的机器人名称将显示在此处，替代 ConvaiBot。

好了，一切完成。您的机器人已启动。请保持运行，以便它能够与用户交互。

{% hint style="warning" %}
如果您在托管过程中遇到任何问题，请通过 <support@convai.com> 联系我们，我们会尽快回复您。

Convai 正在为您寻找托管服务器机器人的解决方案，这样您就不必经历上述步骤中的全部麻烦。等我们有更新后，我们会持续更新文档。
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/other-integrations/discord/hosting-discord-bot-from-personal-server.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
