From 6385222186c12c3a84865845d180e20551f8889f Mon Sep 17 00:00:00 2001 From: Zack Campbell Date: Thu, 10 Aug 2017 17:48:06 -0500 Subject: [PATCH] Allow syncronous Plugin init() methods to compile --- examples/PluginAuthoring.md | 6 +++--- src/client/Plugin.ts | 4 ++-- src/client/interface/IPlugin.ts | 10 ++++++---- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/examples/PluginAuthoring.md b/examples/PluginAuthoring.md index 90087be2..78e655e5 100644 --- a/examples/PluginAuthoring.md +++ b/examples/PluginAuthoring.md @@ -59,7 +59,7 @@ class CustomPlugin extends Plugin this.client = client; } - async init() + init() { console.log('Custom plugin initialized.'); } @@ -75,8 +75,8 @@ instance: The Plugin `init()` method will be called when the plugin is loaded, which is after all storages (including guild storages) are available but before `clientReady` is emitted. Assuming you store the client instance passed in the Plugin constructor -like in the example above, you will be able to use it here. This method is expected -to be async. +like in the example above, you will be able to use it here. This method can be async +if needed to make things easier for yourself. ## Plugin tools diff --git a/src/client/Plugin.ts b/src/client/Plugin.ts index 3c125c4b..08adfbbb 100644 --- a/src/client/Plugin.ts +++ b/src/client/Plugin.ts @@ -22,7 +22,7 @@ import { IPlugin } from './interface/IPlugin'; * is called * *
**Note:** A plugin is expected to have two things at runtime: - * a `name` property containing the name of the plugin, and an async `init()` + * a `name` property containing the name of the plugin, and an `init()` * method that will be called by the framework after loading the plugin.
* See: {@link IPlugin#name} and {@link IPlugin#init}
* @@ -42,5 +42,5 @@ import { IPlugin } from './interface/IPlugin'; export class Plugin implements IPlugin { public name: string; - public async init(): Promise { throw new Error('Plugins must implement the `init` method'); } + public init(): void { throw new Error('Plugins must implement the `init` method'); } } diff --git a/src/client/interface/IPlugin.ts b/src/client/interface/IPlugin.ts index 72e1ba9e..9a7ccca4 100644 --- a/src/client/interface/IPlugin.ts +++ b/src/client/interface/IPlugin.ts @@ -17,16 +17,18 @@ * @type {string} */ /** - * Async method that will be called by the Plugin loader when the + * Method that will be called by the Plugin loader when the * Plugin is loaded. This is the only method that will be called by * the framework automatically, so this should be where anything - * necessary should be done to make the Plugin operational + * necessary should be done to make the Plugin operational. + * + * > This method can be async if desired or needed * @method IPlugin#init - * @returns {Promise} + * @returns {Promise|void} */ export interface IPlugin { name: string; - init(): Promise; + init(): Promise | void; }