mirror of
https://github.com/stoatchat/javascript-client-sdk.git
synced 2026-07-20 20:16:06 -04:00
Add a way to reset the client; add invite_only field.
This commit is contained in:
+1
-1
@@ -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
@@ -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
@@ -7,7 +7,8 @@ export namespace Core {
|
||||
enabled: boolean,
|
||||
key: string,
|
||||
},
|
||||
email: boolean
|
||||
email: boolean,
|
||||
invite_only: string
|
||||
},
|
||||
ws: string
|
||||
}
|
||||
|
||||
+2
-14
@@ -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
@@ -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
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user