返回顶部
d

discord-contextDiscord上下文读取

Read Discord channel and thread message history directly via the Discord Bot API, bypassing OpenClaw's session-based message visibility. Use when you need to read messages from a Discord thread or channel that has no active OpenClaw session, fetch historical context from a conversation you weren't part of, or access thread content that was mentioned but not visible in the current session. Triggers on "read that thread", "what did they say in #channel", "fetch Discord messages", "get thread histo

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
387
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

discord-context

Discord 上下文

问题

OpenClaw 是基于会话的:代理只能看到它们拥有活跃会话的对话中的消息。代理未被提及或未与之交互的 Discord 线程是不可见的——没有内置工具可以读取任意频道/线程历史记录。

此外,OpenClaw 会从 openclaw config get 和环境变量中编辑掉 Discord 机器人令牌(按设计),因此代理无法使用配置的令牌直接调用 Discord API。

解决方案

将 Discord 机器人令牌存储在代理可访问的单独文件中,然后使用 curl 直接调用 Discord API。

设置(一次性操作,以用户身份运行)

bash

将机器人令牌存储在工作区之外的文件中(不会被 git 提交)


echo 你的DISCORD机器人_令牌 > ~/.openclaw/.discord-bot-token
chmod 600 ~/.openclaw/.discord-bot-token

将路径记录在 TOOLS.md 中,以便代理知道在会话之间在哪里找到它。

读取消息

bash

加载令牌


DISCORD_TOKEN=$(cat ~/.openclaw/.discord-bot-token)

从频道或线程读取最近的消息(线程在 Discord 中也是频道)

curl -s -H Authorization: Bot $DISCORD_TOKEN \ https://discord.com/api/v10/channels/{频道或线程ID}/messages?limit=50 \ | python3 -m json.tool

读取特定消息ID之前的消息(分页)

curl -s -H Authorization: Bot $DISCORD_TOKEN \ https://discord.com/api/v10/channels/{频道ID}/messages?limit=50&before={消息ID} \ | python3 -m json.tool

列出公会频道中的活跃线程

curl -s -H Authorization: Bot $DISCORD_TOKEN \ https://discord.com/api/v10/channels/{父频道ID}/threads/active \ | python3 -m json.tool

查找线程/频道ID

  • - 在 Discord 中启用开发者模式:用户设置 → 高级 → 开发者模式
  • 右键点击任何频道或线程 → 复制频道ID
  • 线程ID和频道ID在API中的工作方式相同

关键说明

  • - Discord 默认按最新优先返回消息
  • 每次请求的最大 limit 为 100;使用 before/after 参数进行分页
  • 机器人必须是公会的成员,并拥有查看频道读取消息历史权限
  • 速率限制适用:每个路由每秒 50 个请求(请尊重 429 响应和 Retry-After 头部)

响应字段

每个消息对象包含:

  • - content — 消息文本
  • author.username / author.globalname — 发送者
  • timestamp — 时间戳
  • id — 消息ID(用于分页或回复引用)
  • referencedmessage — 被回复的消息(如果是回复)

安全考虑

  • - 令牌文件权限为 chmod 600,且位于 git 跟踪的工作区之外
  • 机器人令牌授予对机器人所在所有频道的读/写访问权限——请像对待密码一样对待它
  • 优先使用只读 API 调用;不要用于发送消息(请使用 OpenClaw 的原生路由)
  • 如果在 Discord 开发者门户中轮换令牌,请同时更新 openclaw config 和令牌文件

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 discord-history-reader-1776066128 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 discord-history-reader-1776066128 技能

通过命令行安装

skillhub install discord-history-reader-1776066128

下载

⬇ 下载 discord-context v1.0.0(免费)

文件大小: 2.25 KB | 发布时间: 2026-4-15 12:30

v1.0.0 最新 2026-4-15 12:30
Initial release: read Discord channel/thread history via Bot API, bypassing OpenClaw session-based visibility limits

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部