Welcome
danger
The @sapphire/framework
API documentation section of this website is currently based on the main
branch of @sapphire/framework
. This means it will mention any breaking changes that are not yet released to
NPM, including but not limited to support for Application Commands. In the grand scheme of things, this means that the
API documentation may show properties, functions and classes that will not be available until the next major release of
@sapphire/framework
. That said, if you wish to use this next version of @sapphire/framework
in
your project, you can install it by using the @next
tag from NPM.
- npm
- yarn
- pnpm
npm install @sapphire/framework@next
yarn add @sapphire/framework@next
pnpm add @sapphire/framework@next
We are working on fixing this by providing multiple versions of the documentation, similar to what you may be used to from the Discord.js website, however this fix will take some time to be released.
About
Sapphire is a next-gen object-oriented Discord.js bot framework.
Sapphire is a community driven framework that aims to give you all the features you need to make your Discord bot.
With a history of many other Discord bot frameworks (both for NodeJS and other languages) to inspire Sapphire, it has become the ultimate modern experience of writing your code.
Key Features
- Advanced plugin support
- Supports both CommonJS and ESM
- Completely modular and extendable
- Designed with first class TypeScript support in mind
- Includes optional utilities that you can use in any project
Installation
Node.js 16.6.0 or newer is required.
- npm
- yarn
- pnpm
npm install @sapphire/framework discord.js
yarn add @sapphire/framework discord.js
pnpm add @sapphire/framework discord.js
Optional packages
Official Plugins
- @sapphire/plugin-apiExpose a REST API within the same process as your bot.
- @sapphire/plugin-editable-commandsMake it possible to edit your command messages and trigger new commands.
- @sapphire/plugin-i18nextIntegrate i18next into your bot for internationalization.
- @sapphire/plugin-loggerAdd beautiful stylized logging to your bot.
- @sapphire/plugin-subcommandsAdd subcommands to your bot.
Official Utilities and configurations
- @sapphire/cliCLI to generate a new Sapphire bot or add components to your current one.
- @sapphire/utilitiesA plethora of awesome utility functions that are more useful than you can probably imagine.
- @sapphire/ts-configOur ts-config. We use it for all Sapphire projects, but it's also a great starting point for your TypeScript Discord bot.
- @sapphire/discord-utilitiesUseful utilities for any JavaScript/TypeScript based Discord bot.
- @sapphire/discord.js-utilitiesUseful utilities for a bot using Discord.JS such as paginated responses, type checks and prompts.
- @sapphire/decoratorsAwesome decorators that let you write cleaner code.
- @sapphire/fetchA tiny wrapper around cross-fetchthat adds extra ease-of-use and type safety.
- @sapphire/time-utilitiesVarious methods and classes related to manipulating Date and time.
- @sapphire/embed-jsxEver wanted to write your Discord embeds using JSX? Use this library.
- @sapphire/eslint-configOur opinionated ESLint config that we use for all Sapphire projects.
- @sapphire/prettier-configOur opinionated Prettier config that we use for all Sapphire projects.
- @sapphire/event-iteratorTurn your event emitter events into async iterators.
- @sapphire/ratelimitsHandle ratelimits with efficient bucket strategies.
- @sapphire/snowflakeGenerate and parse various forms of Snowflakes.
- @sapphire/stopwatchAccurately measure passing time with this stopwatch utility.
- @sapphire/typeA type detection utility leveraging NodeJS internals.
- @sapphire/async-queueSequential asynchronous lock-based queue for promises.
Example usage
- JavaScript
- ESM
- TypeScript
const { SapphireClient } = require('@sapphire/framework');const client = new SapphireClient({ intents: ['GUILDS', 'GUILD_MESSAGES'] });client.login('your-token-goes-here');
import { SapphireClient } from '@sapphire/framework';const client = new SapphireClient({ intents: ['GUILDS', 'GUILD_MESSAGES'] });client.login('your-token-goes-here');
import { SapphireClient } from '@sapphire/framework';const client = new SapphireClient({ intents: ['GUILDS', 'GUILD_MESSAGES'] });client.login('your-token-goes-here');
Links
- Website (source)
- Documentation
- Guide
- Sapphire Discord Server
- Discord.js Discord server
- Discord Developers Discord server
- GitHub
Contributing
Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the documentation.
See the contribution guide if you'd like to submit a PR.
Help
If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to join our official Sapphire Community Server.