npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dm-bot

v1.1.6

Published

Interactive Discord bot with OpenCode integration

Downloads

840

Readme

Discord 交互式机器人

Node.js Version License: MIT Discord.js

一个基于 Discord.js 的交互式机器人,集成 OpenCode 功能,支持私聊对话和消息队列管理。

功能特性

  • 私聊消息处理
  • 消息队列管理(防止并发处理)
  • 用户 Session 持久化
  • OpenCode 集成
  • SQLite 数据存储
  • 支持以下命令:
    • !help - 显示帮助信息
    • !reset - 清空消息队列
    • !status - 查看机器人状态

环境要求

  • Node.js >= 18.0.0
  • npm 或 yarn
  • OpenCode CLI(用于 AI 功能)

快速开始

1. 克隆仓库

git clone https://github.com/958877748/skills.git
cd discord-bot

2. 安装依赖

npm install

3. 配置环境变量

cp .env.example .env
# 编辑 .env 文件,填入你的 Discord 机器人令牌

4. 获取 Discord 机器人令牌

  1. 访问 Discord Developer Portal
  2. 点击 "New Application" 创建新应用
  3. 进入 "Bot" 标签页,点击 "Add Bot"
  4. 在 "Privileged Gateway Intents" 中启用:
    • MESSAGE CONTENT INTENT
  5. 复制 Bot Token 到 .env 文件

5. 邀请机器人到服务器

  1. 在 Developer Portal 中,进入 "OAuth2" -> "URL Generator"
  2. 在 SCOPES 中选择 bot
  3. 在 BOT PERMISSIONS 中选择:
    • Send Messages
    • Read Message History
    • Read Messages/View Channels
  4. 复制生成的 URL 并在浏览器中打开,选择要添加的服务器

6. 启动机器人

# 生产环境
npm start

# 开发环境(带自动重启)
npm run dev

或者使用脚本:

# Linux/Mac
chmod +x start.sh
./start.sh

# Windows
start.bat

使用方法

  1. 向机器人发送私信开始对话
  2. 使用以下命令:
    • !help - 显示帮助信息
    • !reset - 清空当前队列
    • !status - 查看机器人运行状态

项目结构

discord-bot/
├── index.js          # 主入口文件
├── db.js             # 数据库操作模块
├── .env.example      # 环境变量示例
├── .gitignore        # Git 忽略配置
├── package.json      # 项目配置
├── start.sh          # Linux/Mac 启动脚本
├── start.bat         # Windows 启动脚本
└── README.md         # 项目说明

数据库

使用 SQLite 存储数据:

  • message_queue - 消息队列表
  • user_sessions - 用户 Session 表

数据库文件会自动创建,无需手动初始化。

注意事项

  • 机器人只处理私聊消息,服务器中的消息将被忽略
  • 确保 OpenCode CLI 已安装并可用
  • 不要将 .env 文件提交到版本控制
  • 数据库文件 (*.db) 不会被 Git 追踪

故障排除

机器人不响应消息

  • 检查 Bot Token 是否正确
  • 确认 MESSAGE CONTENT INTENT 已启用
  • 查看控制台是否有错误信息

OpenCode 执行失败

  • 确保 OpenCode CLI 已安装: opencode --version
  • 检查 opencode 是否在系统 PATH 中

许可证

MIT