UNPKG

@lilybird/transformers

Version:
52 lines (51 loc) 1.49 kB
import { CDN } from "lilybird"; export class User { id; username; discriminator; globalName; avatar; bot; system; mfaEnabled; banner; accentColor; locale; verified; email; flags; premiumType; publicFlags; avatarDecoration; client; constructor(client, user) { this.client = client; this.id = user.id; this.username = user.username; this.discriminator = user.discriminator; this.globalName = user.global_name; this.avatar = user.avatar; this.bot = user.bot ?? false; this.system = user.system ?? false; this.mfaEnabled = user.mfa_enabled ?? false; this.banner = user.banner; this.accentColor = user.accent_color; this.locale = user.locale; this.verified = user.verified ?? false; this.email = user.email; this.flags = user.flags ?? 0; this.premiumType = user.premium_type ?? 0; this.publicFlags = user.public_flags ?? 0; this.avatarDecoration = user.avatar_decoration; } avatarURL(options) { if (this.avatar === null) return CDN.defaultUserAvatarURL(this.#calculateIndex(), options); return CDN.userAvatarURL(this.id, this.avatar, options); } #calculateIndex() { if (this.discriminator === "0") return ((BigInt(this.id) >> 22n) % 6n).toString(); return (+this.discriminator % 5).toString(); } }