> 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-replit.md).

# 从 Replit 托管 Discord Bot

### [Repl 链接](https://replit.com/@Himadri-Sankar2/ConvaiDiscordIntegration?v=1)

以下是成功从 Replit 运行 Discord 机器人服务器的步骤：

### 步骤：

1. 注册 [Replit](https://replit.com/)，然后访问上面提到的链接，进入已发布的 Repl。
2. 进入页面后，点击 **Fork Repl**.

   点击弹出的通知中的 **Fork Repl** 。

   <figure><img src="/files/b9667a739ef22c35afd44344a4996efbef28f752" alt=""><figcaption></figcaption></figure>
3. 这将在你的账户中创建该代码的一个分支。成功 Fork 之后，代码会在编辑器中打开供你使用。

   <figure><img src="/files/36919ead832b254bb91a53fc7eec8a4fb50d8bc2" alt=""><figcaption></figcaption></figure>
4. 前往 **Secrets** ，位于屏幕左下角。

   <figure><img src="/files/2889ad9aee725e5f7ec0ab0630b14ab676718949" alt=""><figcaption></figcaption></figure>
5. 现在添加以下凭据。请直接从这里复制密钥，以避免任何拼写错误。

   1. Convai API 密钥详情：

      ```properties
      密钥：CONVAI_API_KEY
      值：<你在 Convai 获取的唯一 API 密钥>
      ```
   2. Convai 角色 ID：

      ```properties
      密钥：CONVAI_CHARACTER_ID
      值：<你在 Convai 网站上设计的角色的唯一 ID>
      ```
   3. 允许的频道：

      ```properties
      密钥：ALLOWED_CHANNELS
      值：<用 ',' 分隔写出频道名称。例如：'chat-with-convaibot,interactive-avatars'>
      ```
   4. Discord 机器人详情：

      ```properties
      密钥：DISCORD_BOT_TOKEN
      值：<创建 Discord 机器人时生成的令牌>
      ```

   注意：ALLOWED\_CHANNELS 会限制机器人只在列表中提到的频道中响应。这会影响机器人被邀请加入的所有服务器。若要添加新服务器，你需要在列表中加入新的允许频道列表。这也可能需要你重新运行该 Repl。
6. 在你输入完详情后，它应该看起来像这样

   <figure><img src="/files/c073be76d70693d1027cfe928af1ecd95cafff10" alt=""><figcaption></figcaption></figure>
7. 然后点击顶部的 **运行** 按钮来启动机器人。一旦你看到日志显示机器人已启动，就全部完成了。


---

# 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-replit.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.
