跳到主要内容

接入Discord

接入Discord Bot机器人​

OpenClaw 的 Discord 接入方式,是 OpenClaw 主动拿 Bot Token 连 Discord 官方网关

重新接入新的Bot​

如果你只是把旧 bot 换成了一个新的 bot,OpenClaw 这边通常只需要把 Discord token 改成新的,然后重启 Gateway

  • 删除之前的bot,或者只修改token
bash
openclaw channels list
# 移除之前的bot
openclaw channels remove --channel discord --delete
# 重新配置
openclaw config
  • 打开OpenClaw Configuration 配置:~/.openclaw/openclaw.json
    • Linux / WSL/Mac:~/.openclaw/openclaw.json
    • Windows:通常等价于 C:\Users\你的用户名\.openclaw\openclaw.json
bash
# 查看配置文件
openclaw config file
  • 配置文件修改
bash
{
"channels": {
"discord": {
"enabled": true,
"token": "你的新_BOT_TOKEN"
}
}
}

虚拟机上连接Discord网络问题​

  • 主机配置了vpn代理,但是到了虚拟机上网络没通
  • 需要在虚拟机上配置代理端口
bash
# 测试是否能连接上
curl -I https://discord.com
  • 查看window的代理端口
    • 通常代理端口为 127.0.0.1开头
    • 我这边的端口为 127.0.0.1:28002
bash
# 查看监听的端口
netstat -ano | findstr LISTENING
# 8824是对应的pid,查看这个代理软件输出结果
tasklist | findstr 8824
  • 在虚拟机上设置代理端口

    • 临时设置
    bash
    export http_proxy=http://127.0.0.1:28002
    export https_proxy=http://127.0.0.1:28002
    export HTTP_PROXY=http://127.0.0.1:28002
    export HTTPS_PROXY=http://127.0.0.1:28002
    • 把代理写进 ~/.bashrc 配置文件 (永久配置)

      • 使用vim进入编辑模式
      • 重新加载配置:source ~/.bashrc
      bash
      export http_proxy=http://127.0.0.1:28002
      export https_proxy=http://127.0.0.1:28002
      export HTTP_PROXY=http://127.0.0.1:28002
      export HTTPS_PROXY=http://127.0.0.1:28002
      export no_proxy=localhost,127.0.0.1,::1
      export NO_PROXY=localhost,127.0.0.1,::1
      export NODE_USE_ENV_PROXY=1
  • 输入代理配置输出,检查代理是否配置成功

bash
echo $http_proxy
echo $https_proxy
echo $ALL_PROXY