Skip to content

Instantly share code, notes, and snippets.

@StephanBijzitter
Created December 3, 2019 14:04
Show Gist options
  • Save StephanBijzitter/6cee238bf73042ca37666ed2b5384df1 to your computer and use it in GitHub Desktop.
Save StephanBijzitter/6cee238bf73042ca37666ed2b5384df1 to your computer and use it in GitHub Desktop.
export abstract class StephanPlugin<O, D> {
/**
* Called right after Stephan loads the plugin file.
*
* Avoid performing any heavy actions here, as that will present
* significant performance implications for Stephan's startup time!
*
* @example
*```typescript
* type Options = {
* verbose?: boolean;
* token?: string;
* }
*
* export const defaultOptions = {
* verbose: false
* };
*
* class StephanPluginExample extends Plugin<Options, typeof defaultOptions> {
*
* public constructor(args) {
* super(args, myDefaultOptions);
* }
* }
* ```
*
* Note that your Options type should only have optional properties for your own
* convenience, as Stephan will provide an empty object in case the user did
* not specify their own options!
*
* @param args Arguments compiled and provided by StephanClient.
* @param args.options The options as provided by the user, or an empty object if not provided.
* @param defaultOptions The default options as provided by the plugin, or an empty object.
*/
public constructor({options, client}: {
options: O;
client: unknown;
}, defaultOptions: D) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment