diff --git a/src/Client.ts b/src/Client.ts index 3119525c..6782c702 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -395,6 +395,18 @@ export class Client extends AsyncEventEmitter { this.connect(); } + /** + * Log out of current session + * + * This function prepares the client for disposal by removing all event listeners and killing the events socket. + */ + async logout(): Promise { + await this.api.post("/auth/session/logout"); + this.events.removeAllListeners(); + this.removeAllListeners(); + this.events.disconnect(); + } + /** * Prepare a markdown-based message to be displayed to the user as plain text. * @param source Source markdown text