Welcome
The @sapphire/framework
API documentation section of this website is written for the 3.x
version
of @sapphire/framework
. For the longer users of the framework who may have started with an earlier major
version we encourage you to read our updating guide.
- npm
- yarn
- pnpm
npm install @sapphire/framework
yarn add @sapphire/framework
pnpm add @sapphire/framework
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 18.x or newer is required.
- npm
- yarn
- pnpm
npm install @sapphire/framework discord.js@14.x
yarn add @sapphire/framework discord.js@14.x
pnpm add @sapphire/framework discord.js@14.x
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-hmrAdd hot module reloading for pieces.
- @sapphire/plugin-i18nextIntegrate i18next into your bot for internationalization.
- @sapphire/plugin-loggerAdd beautiful stylized logging to your bot.
- @sapphire/plugin-pattern-commandsAdd support for pattern commands.
- @sapphire/plugin-scheduled-tasksAdd support for Redis or Amazon SQS powered scheduled tasks.
- @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/shapeshiftBlazing fast input validation and transformation ⚡
- @sapphire/utilitiesA plethora of awesome utility functions that are more useful than you can probably imagine.
- @sapphire/resultA TypeScript port of Nightly Rust's Result and Option structs.
- @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/lexureParser and utilities for non-technical user input.
- @sapphire/node-utilitiesNode specific JavaScript utilities for the Sapphire Community.
- @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/cronA cron utility library for JavaScript.
- @sapphire/durationA time duration utility library for JavaScript.
- @sapphire/timer-managerA timer manager utility library for JavaScript.
- @sapphire/timestampA timestamp utility library for JavaScript.
- @sapphire/time-utilitiesVarious methods and classes related to manipulating Date and time.
- @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.
- @sapphire/bitfieldA bitfield utility library for JavaScript.
- @sapphire/phishermanWrapper around phisherman to easily check and report domains.
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.