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

carbon-proxy

v0.14.5

Published

<div align="center"> <a href="https://github.com/stonev5/carbon"><img src="https://cdn.buape.com/carbon/wordmark.png" alt="Carbon Wordmark"></a>

Downloads

788

Readme

Carbon Proxy

Carbon 框架的代理增强版 - 支持通过 HTTP/SOCKS5 代理访问 Discord API

这是基于 @buape/carbon 的 fork 版本,增加了对代理的支持,方便在需要代理的环境中使用。

✨ 新增特性

本版本在原版基础上新增:

  • 🔒 HTTP 代理支持 - 通过 HTTP 代理访问 Discord API
  • 🧦 SOCKS5 代理支持 - 支持 SOCKS5 协议的代理
  • ⚙️ 灵活配置 - 支持环境变量和代码配置两种方式
  • 🌍 国际化友好 - 完美支持中国大陆等需要代理的地区

原版特性

Carbon 是一个功能完善的 Discord HTTP 框架,使用 TypeScript 构建,设计简洁易懂。

  • 完全兼容 Discord API
  • 灵活强大
  • 基于类的系统,易于复用
  • 支持多平台部署(Node.js、Cloudflare Workers、Bun、Next.js)

📦 安装

npm install carbon-proxy
# 或
pnpm add carbon-proxy
# 或
yarn add carbon-proxy

🚀 快速开始

基础用法(不带代理)

import { Client } from "carbon-proxy"

const client = new Client({
  clientId: "your-client-id",
  publicKey: "your-public-key",
  token: "your-bot-token",
  baseUrl: "http://localhost:3000"
})

client.startServer()

使用 HTTP 代理

方式一:环境变量(推荐)

# 设置代理环境变量
export HTTPS_PROXY="http://127.0.0.1:7891"
export HTTP_PROXY="http://127.0.0.1:7891"

# 或使用 Discord 专用代理变量
export DISCORD_HTTP_PROXY="http://127.0.0.1:7891"

# 运行你的 bot
node dist/index.js

方式二:代码配置

import { Client } from "carbon-proxy"

const client = new Client({
  clientId: "your-client-id",
  publicKey: "your-public-key",
  token: "your-bot-token",
  baseUrl: "http://localhost:3000",
  requestOptions: {
    proxy: "http://127.0.0.1:7891"
  }
})

client.startServer()

使用 SOCKS5 代理

环境变量方式:

export ALL_PROXY="socks5://127.0.0.1:7892"
node dist/index.js

代码配置方式:

import { Client } from "carbon-proxy"

const client = new Client({
  clientId: "your-client-id",
  publicKey: "your-public-key",
  token: "your-bot-token",
  baseUrl: "http://localhost:3000",
  requestOptions: {
    proxy: "socks5://127.0.0.1:7892"
  }
})

client.startServer()

🔧 代理配置说明

支持的代理格式

  • HTTP 代理: http://host:porthttp://user:pass@host:port
  • HTTPS 代理: https://host:porthttps://user:pass@host:port
  • SOCKS 代理: socks://host:port, socks4://host:port, socks5://host:port

环境变量优先级

按优先级从高到低:

  1. DISCORD_HTTP_PROXY - Discord 专用代理
  2. HTTPS_PROXY - HTTPS 请求代理
  3. HTTP_PROXY - HTTP 请求代理
  4. ALL_PROXY - 所有请求代理

常用代理软件配置

Clash

export HTTP_PROXY="http://127.0.0.1:7890"
export HTTPS_PROXY="http://127.0.0.1:7890"

V2Ray

export HTTP_PROXY="http://127.0.0.1:10809"
export HTTPS_PROXY="http://127.0.0.1:10809"

Shadowsocks (需要 SOCKS5 支持)

export ALL_PROXY="socks5://127.0.0.1:7891"

📖 完整示例

import { Client, Intents } from "carbon-proxy"
import { MyCommand } from "./commands/MyCommand"

const client = new Client({
  clientId: process.env.CLIENT_ID!,
  publicKey: process.env.PUBLIC_KEY!,
  token: process.env.TOKEN!,
  baseUrl: "http://localhost:3000",
  // 配置代理(可选,也可以用环境变量)
  requestOptions: {
    proxy: process.env.DISCORD_HTTP_PROXY
  }
})

// 注册命令
client.registerCommand(MyCommand)

// 启动服务器
client.startServer()

🧪 测试代理连接

项目包含代理测试脚本,可以快速验证代理配置:

cd node_modules/carbon-proxy

# 测试 HTTP 代理
DISCORD_BOT_TOKEN="your_token" HTTPS_PROXY="http://127.0.0.1:7891" node test-proxy.mjs

# 测试 SOCKS5 代理
DISCORD_BOT_TOKEN="your_token" ALL_PROXY="socks5://127.0.0.1:7892" node test-proxy.mjs

🔍 故障排查

代理连接失败

  1. 确认代理服务正在运行

    curl -x http://127.0.0.1:7891 https://www.google.com
  2. 检查代理格式

    • 确保使用正确的协议前缀:http://, socks5://
    • 确保端口号正确
  3. 检查代理认证

    • 如果代理需要认证,使用格式:http://username:password@host:port

请求超时

  • 增加请求超时时间(如果支持)
  • 检查代理服务器的网络连接
  • 尝试切换到不同的代理协议(HTTP → SOCKS5)

📚 相关资源

🤝 贡献

欢迎提交 Issue 和 Pull Request!

📄 许可证

MIT License - 基于 @buape/carbon 修改

🙏 致谢

感谢 buape 开发了这么优秀的 Carbon 框架!


注意: 本版本是 fork 的增强版,主要用于需要代理的场景。如果你不需要代理功能,建议使用原版