@amelix/phoenix.js
Version:
A feature-rich API wrapper for the critically acclaimed chatting app Phoenix.. or something.
34 lines (33 loc) • 1.2 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Base_1 = require("./Base");
const config_1 = require("../config");
class User extends Base_1.default {
constructor(client, data) {
super(client, data);
this.username = data.username;
this.avatarLastUpdated = data.avatarLastUpdated;
if (data.defaultAvatar) {
this.avatarURL = config_1.defaultIcon;
}
else {
this.avatarURL = `https://${config_1.hostname}${config_1.apiPath}/avatars/${this.id}`;
}
this.bot = data.bot || false;
if (data.mutualServers)
this.mutualServers = data.mutualServers;
}
/** Calculate all the mutual servers between the client and this user. */
getMutualServers() {
if (this.mutualServers)
return this.mutualServers;
let mutualServers = new Map();
this.client.servers.forEach(server => {
if (server.members.has(this.id))
mutualServers.set(server.id, server);
});
this.mutualServers = mutualServers;
return mutualServers;
}
}
exports.default = User;