import {Channel} from "./channel.js" import {Message} from "./message.js" class Channels { constructor(client) { this.client = client; } async createChannel(users_id, reload) { let null_id = false; users_id.forEach(user_id => { if (user_id == null) null_id = true; }); if (null_id) return console.log(users_id, "createChannel error, null id;"); 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}