Files
discord-decomp/records/InviteRecord.tsx
T
2026-11-01 12:12:55 +02:00

55 lines
1.6 KiB
TypeScript

// Metro module 6697 (f6698).
import Record from "../lib/Record";
import Module3771 from "../_bundle/Module3771";
class InviteRecord extends Record {
constructor(a0) {
super();
const code = a0.code || "";
this.code = code;
this.temporary = a0.temporary || false;
this.revoked = a0.revoked || false;
this.uses = a0.uses || 0;
this.maxUses = a0.maxUses || 0;
this.maxAge = a0.maxAge || 0;
this.createdAt = a0.createdAt || new Date();
this.channel = a0.channel;
this.guild = a0.guild;
this.inviter = a0.inviter || null;
this.targetType = a0.targetType || null;
this.targetUser = a0.targetUser || null;
this.targetApplication = a0.targetApplication || null;
this.type = a0.type || null;
this.flags = a0.flags || 0;
this.roles = a0.roles || [];
}
static createFromServer(a0) {
let created_at = a0.created_at;
if (created_at == null) {
created_at = void 0;
}
return new InviteRecord({
...a0,
maxUses: a0.max_uses,
maxAge: a0.max_age,
createdAt: Module3771(created_at),
targetType: a0.target_type,
targetUser: a0.target_user,
targetApplication: a0.target_application
});
}
isExpired() {
const maxAge = this.maxAge;
if (maxAge > 0 && Module3771(this.createdAt).add(maxAge, "seconds").isBefore(Date.now())) {
return true;
}
return false;
}
getExpiresAt() {
return this.maxAge > 0 ? Module3771(this.createdAt).add(this.maxAge, "seconds").toDate() : Infinity;
}
toString() {
return this.code;
}
}
export default InviteRecord;