mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-03 05:26:07 +00:00
34 lines
837 B
TypeScript
34 lines
837 B
TypeScript
import type { DiscordUser, Session } from "./deps.ts";
|
|
import { User } from "./deps.ts";
|
|
import { Collection } from "./Collection.ts";
|
|
|
|
export class CachedUser extends User {
|
|
constructor(session: Session, data: DiscordUser) {
|
|
super(session, data);
|
|
|
|
CachedUser.from(this);
|
|
}
|
|
|
|
_id!: bigint;
|
|
|
|
static from(user: User): CachedUser {
|
|
const target: CachedUser = Object.assign(user, { _id: BigInt(user.id) });
|
|
|
|
Object.defineProperty(target, "id", {
|
|
get(this: CachedUser) {
|
|
return String(this._id);
|
|
}
|
|
});
|
|
|
|
return target;
|
|
}
|
|
}
|
|
|
|
export class UserCache extends Collection<bigint, CachedUser> {
|
|
constructor(session: Session, entries: Iterable<readonly [bigint, User]>) {
|
|
super(session, entries);
|
|
}
|
|
}
|
|
|
|
export default UserCache;
|