Add a way to reset the client; add invite_only field.

This commit is contained in:
Paul Makles
2021-02-13 20:05:01 +00:00
parent e205f3f7d6
commit 993144c8ec
6 changed files with 17 additions and 21 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "revolt.js",
"version": "3.0.2",
"version": "3.0.3-alpha.0",
"main": "dist/index.js",
"repository": "https://gitlab.insrt.uk/revolt/revolt.js",
"author": "Paul Makles <insrt.uk>",
+10 -1
View File
@@ -205,10 +205,19 @@ export class Client extends EventEmitter {
* Utility functions.
*/
async logout() {
this.websocket.disconnect();
this.reset();
await this.req('GET', '/auth/logout');
}
reset() {
this.websocket.disconnect();
delete this.user;
delete this.session;
this.users = new Map();
this.channels = new Map();
this.messages = new Map();
}
register(apiURL: string, data: Route<'POST', '/auth/create'>["data"]) {
return this.request('POST', '/auth/create', { data, baseURL: apiURL });
}
+2 -1
View File
@@ -7,7 +7,8 @@ export namespace Core {
enabled: boolean,
key: string,
},
email: boolean
email: boolean,
invite_only: string
},
ws: string
}
+2 -14
View File
@@ -1,4 +1,4 @@
import { Auth, Channels, Users } from './objects';
import { Channels, Core, Users } from './objects';
type Routes =
/**
@@ -9,19 +9,7 @@ type Routes =
method: 'GET',
route: '/',
data: undefined,
response: {
revolt: string,
features: {
registration: boolean,
captcha: {
enabled: boolean,
key: string,
},
email: boolean,
invite_only: boolean
},
ws: string
}
response: Core.RevoltNodeConfiguration
}
/**
* Auth
+1 -1
View File
@@ -4,7 +4,7 @@ export { default as User } from './objects/User';
export { default as Message } from './objects/Message';
export { default as Channel, SavedMessagesChannel, DirectMessageChannel, GroupChannel } from './objects/Channel';
export const LIBRARY_VERSION = '3.0.2';
export const LIBRARY_VERSION = '3.0.3-alpha.0';
export const defaultConfig = {
apiURL: 'https://api.revolt.chat',
+1 -3
View File
@@ -1,9 +1,7 @@
import { config } from 'dotenv';
config();
import { Channel, Client, User } from ".";
import { GroupChannel } from './objects/Channel';
import { SystemUser } from './objects/User';
import { Client } from ".";
let client = new Client();
client.once('ready', async () => {