import { Client } from "./client.js"; class Profile { /** * @param {Client} client */ constructor (client, username = undefined, avatar_url = undefined, user_id = undefined) { /** * @type {Client} client */ this.client = client; this.username = username; this.avatar_url = avatar_url; this.user_id = user_id; this.isBlocked = false; } async init(user_id) { let response = await this.client._get(`/api/profiles/${user_id}`); if (response.status === 404) return 1; let response_data = await response.json(); this.user_id = response_data.user_id; this.username = response_data.username; this.avatar_url = response_data.avatar_url; let block_response = await this.client._get("/api/profiles/block"); if (block_response.status == 404) return let block_data = await block_response.json(); let block_list = JSON.parse(block_data); block_list.forEach(block => { let blocker = block.fields.blocker; let blocked = block.fields.blocked; if (blocker == this.client.me.user_id && blocked == user_id) return this.isBlocked = true; }); } } export {Profile}