Description
This plugin provides an API endpoint for your bot that can be called from external services. A good exemplary use case for this is once your bot grows to have enough configuration options that you want to offer a website to your end-users to change those settings, and your website needs to interface with the bot for this to work.
Features
- Fully ready for TypeScript!
- Provides a Decorator-based API to make developing your routes easy!
- Follows common REST standards.
- Includes ESM ready entrypoint
- Premade OAuth 2.0 endpoints
Installation
@sapphire/plugin-api
depends on the following packages. Be sure to install these along with this package!
You can use the following command to install this package, or replace npm install
with your package manager of choice.
npm install @sapphire/plugin-api @sapphire/framework discord.js discord-api-types
Usage
Start by importing the registration file in your project to use the plugin:
JavaScript
require('@sapphire/plugin-api/register');
TypeScript
import '@sapphire/plugin-api/register';
Then, you can use the following configuration options in your SapphireClient extension class or initializer. This will either be located in your new SapphireClient
constructor call, or super
in your constructor method if you use an extension class.
{
auth: {
id: '',
secret: '',
cookie: 'SAPPHIRE_AUTH',
redirect: '',
scopes: ['identify'],
transformers: []
},
prefix: '',
origin: '*',
listenOptions: {
port: 4000
}
}
API Documentation
For the full API documentation please refer to the TypeDoc generated documentation.
Buy us some doughnuts
Sapphire Community is and always will be open source, even if we don't get donations. That being said, we know there are amazing people who may still want to donate just to show their appreciation. Thank you very much in advance!
We accept donations through Open Collective, Ko-fi, Paypal, Patreon and GitHub Sponsorships. You can use the buttons below to donate through your method of choice.
Contributors โจ
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!