gcommands
gcommands copied to clipboard
refactor: Plugins
Please describe the changes this PR makes and why it should be merged: This PR refactors inhibitors so that they more useful in several cases. Below is an example of how to use plugins now, and some internal systems have been changed/renamed to support/use this new system. These new plugins can provide better support for typescript, and adds more use cases in general, like a database of choice.
import { container, GClient, Plugin, PluginHookType } from 'gcommands';
new Plugin({
name: 'some-plugin',
[PluginHookType.AfterInitialization]: (client: GClient) => {
container.somePlugin = client.options.somePlugin;
},
});
declare module 'gcommands' {
// add somePlugin to the client options
interface GClientOptions {
somePlugin: number;
}
// add somePlugin to the container
interface Container {
somePlugin: number;
}
}
Yes, this system is inspired by @sapphire/framework plugin system.
Status and versioning classification:
- This PR changes the library's interface (methods or parameters added)
- This PR includes breaking changes (methods removed or renamed, parameters moved or removed)