etienne apprend à coder pitié

This commit is contained in:
AdrienLSH
2024-05-14 08:16:21 +02:00
parent c4dc5b4e39
commit e2d56cff85
9 changed files with 126 additions and 170 deletions

View File

@ -1,6 +1,6 @@
import {Channel} from "./Channel.js";
class Channels {
export default class Channels {
constructor(client) {
this.client = client;
this.channel = undefined;
@ -8,32 +8,16 @@ class Channels {
async createChannel(members_id, reload) {
let response = await this.client._post("/api/chat/", {
const response = await this.client._post("/api/chat/", {
members_id:members_id
});
if (response.status >= 300)
return undefined;
let data = await response.json();
const data = await response.json();
console.log(data)
let messages;
if (response.status == 200)
messages = data.messages;
this.channel = new Channel(this.client, data.channel_id, members_id, messages, reload);
return this.channel;
this.channel = new Channel(this.client, data.id, members_id, data.messages, reload);
}
async deleteChannel(members_id) {
let response = await this.client._delete("/api/chat/", {
members_id:members_id
});
let data = await response.json();
return data;
}
}
export {Channels};