38 lines
784 B
JavaScript
38 lines
784 B
JavaScript
import {Channel} from "./channel.js"
|
|
import {Message} from "./message.js"
|
|
|
|
class Channels {
|
|
constructor(client) {
|
|
this.client = client;
|
|
}
|
|
|
|
async createChannel(users_id, reload) {
|
|
let response = await this.client._post("/api/chat/", {
|
|
users_id:users_id
|
|
});
|
|
|
|
let data = await response.json();
|
|
let exit_code = await response.status;
|
|
if (exit_code >= 300)
|
|
return undefined;
|
|
|
|
let messages = undefined;
|
|
if (exit_code == 200)
|
|
messages = data.messages;
|
|
return new Channel(this.client, data.channel_id, users_id, messages, reload);
|
|
}
|
|
|
|
async deleteChannel(users_id) {
|
|
let response = await this.client._delete("/api/chat/", {
|
|
users_id:users_id
|
|
});
|
|
|
|
let data = await response.json();
|
|
console.log(response.status)
|
|
return data;
|
|
}
|
|
|
|
}
|
|
|
|
export {Channels}
|