Skip to content
项目

关于

A fully-featured HTTP library for Discord bots

开发工具

这些数字如何统计

可以做什么

  • Build every common interaction type in one place: slash commands, user/message commands, buttons, select menus, and modals.
  • Start with simple HTTP interactions, then add Gateway or Gateway Forwarder only when your bot needs non-interaction events.
  • Run the same bot across Node.js, Bun, and Fetch-style runtimes like Cloudflare Workers or Next.js.
  • Components can register themselves automatically, and you can still register them globally or per command when you need persistence.

实测星标增长

24小时
0
7天
0
15天
+1
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

Carbon

Carbon WordmarkDiscord NPM Version NPM Downloads

Carbon is a fully typed Discord bot framework for TypeScript that helps you ship quickly with HTTP interactions first, then scale into richer features through plugins, reusable classes, and optional Gateway support without rewriting your architecture later.

Features

  • Build every common interaction type in one place: slash commands, user/message commands, buttons, select menus, and modals.
  • Start with simple HTTP interactions, then add Gateway or Gateway Forwarder only when your bot needs non-interaction events.
  • Run the same bot across Node.js, Bun, and Fetch-style runtimes like Cloudflare Workers or Next.js.
  • Components can register themselves automatically, and you can still register them globally or per command when you need persistence.
  • For quick flows, you can parse custom IDs cleanly and wait for a single component click with replyAndWaitForComponent.
  • Use prechecks and wildcard handlers to add safety rules and fallback behavior without turning command code into a mess.
  • Host multiple Discord applications from one deployment with ClientManager.
  • Grow through plugins like Linked Roles, Command Data, Paginator, Sharding, and Voice.
  • Tune request/event processing with queue lanes, concurrency controls, and runtime metrics when traffic grows.

Installation

To get started with Carbon, you can check out the Getting Started guides for your preferred platform.

Caching

Carbon is serverless-first, so entity caching is off by default. Opt in with the cache plugin:

import { MemoryCachePlugin } from "@buape/carbon/cache"

const client = new Client(options, handlers, [
	new MemoryCachePlugin({
		default: { maxSize: 5000, ttl: 60_000 },
		types: {
			users: { maxSize: 20_000, ttl: 300_000 },
			messages: { maxSize: 1000, ttl: 30_000 }
		}
	})
])

Redis-compatible clients are supported without adding Redis to Carbon's core bundle:

import { RedisCachePlugin } from "@buape/carbon/cache"

const client = new Client(options, handlers, [
	new RedisCachePlugin({ client: redis, prefix: "my-bot" })
])

Custom stores only need small get, set, and delete style methods and can be configured globally or per cache type.

Useful Links

Contributing

We welcome contributions to Carbon! If you're interested in contributing, please check out the Contributing Guide for more information, and join our Discord to get involved!

探索相关项目

加载中…