接入Discord
- 参考问题:https://zhuanlan.zhihu.com/p/2001934699661137919
- discord开发者后台:https://discord.com/developers/applications
接入Discord Bot机器人
OpenClaw 的 Discord 接入方式,是 OpenClaw 主动拿 Bot Token 连 Discord 官方网关
-
创建服务器
-
创建服务器之后,进入开发者后台
-
创建应用
- 注意需要完善个人信息,验证邮箱
-
进入到Bot,获取token
- 复制token:
- MTQ4MzQ5NDMzODY3ODc1NTUyMA.G12oDf.mA-CCzxg1B94H_6IvlKAQK5XjLdBg79O3S286E
- 复制token:
-
进入 OAuth2 配置页面,勾选 Bot
-
设置Bot机器人权限
- 找到 Bot Permissions,勾选 Send Messages 和 Read Message History
-
复制生成的 Bot 链接
-
将 Bot 加入服务器
重新接入新的Bot
如果你只是把旧 bot 换成了一个新的 bot,OpenClaw 这边通常只需要把 Discord token 改成新的,然后重启 Gateway
- 删除之前的bot,或者只修改token
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
- Linux / WSL/Mac:
# 查看配置文件
openclaw config file
- 配置文件修改
{
"channels": {
"discord": {
"enabled": true,
"token": "你的新_BOT_TOKEN"
}
}
}
虚拟机上连接Discord网络问题
- 主机配置了vpn代理,但是到了虚拟机上网络没通
- 需要在虚拟机上配置代理端口
# 测试是否能连接上
curl -I https://discord.com
- 查看window的代理端口
- 通常代理端口为 127.0.0.1开头
- 我这边的端口为 127.0.0.1:28002
# 查看监听的端口
netstat -ano | findstr LISTENING
# 8824是对应的pid,查看这个代理软件输出结果
tasklist | findstr 8824
-
在虚拟机上设置代理端口
- 临时设置
export http_proxy=http://127.0.0.1:28002export https_proxy=http://127.0.0.1:28002export HTTP_PROXY=http://127.0.0.1:28002export HTTPS_PROXY=http://127.0.0.1:28002-
把代理写进
~/.bashrc配置文件 (永久配置)- 使用vim进入编辑模式
- 重新加载配置:source ~/.bashrc
export http_proxy=http://127.0.0.1:28002export https_proxy=http://127.0.0.1:28002export HTTP_PROXY=http://127.0.0.1:28002export HTTPS_PROXY=http://127.0.0.1:28002export no_proxy=localhost,127.0.0.1,::1export NO_PROXY=localhost,127.0.0.1,::1export NODE_USE_ENV_PROXY=1
-
输入代理配置输出,检查代理是否配置成功
echo $http_proxy
echo $https_proxy
echo $ALL_PROXY