mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-03 05:26:07 +00:00
68 lines
1.8 KiB
TypeScript
68 lines
1.8 KiB
TypeScript
import type { Session } from "../session/Session.ts";
|
|
import type { DiscordInvite } from "../vendor/external.ts";
|
|
import { TargetTypes } from "../vendor/external.ts";
|
|
import InviteGuild from "./InviteGuild.ts";
|
|
import User from "./User.ts";
|
|
|
|
/**
|
|
* @link https://discord.com/developers/docs/resources/invite#invite-object
|
|
*/
|
|
export class Invite {
|
|
constructor(session: Session, data: DiscordInvite) {
|
|
this.session = session;
|
|
|
|
if (data.guild) {
|
|
this.guild = new InviteGuild(session, data.guild);
|
|
}
|
|
|
|
if (data.approximate_member_count) {
|
|
this.approximateMemberCount = data.approximate_member_count;
|
|
}
|
|
|
|
if (data.approximate_presence_count) {
|
|
this.approximatePresenceCount = data.approximate_presence_count;
|
|
}
|
|
|
|
// TODO: fix this
|
|
// this.channel = data.channel;
|
|
this.code = data.code;
|
|
|
|
if (data.expires_at) {
|
|
this.expiresAt = Number.parseInt(data.expires_at);
|
|
}
|
|
|
|
// TODO: fix this
|
|
// this.xd = data.guild_scheduled_event
|
|
|
|
if (data.inviter) {
|
|
this.inviter = new User(session, data.inviter);
|
|
}
|
|
|
|
if (data.target_user) {
|
|
this.targetUser = new User(session, data.target_user);
|
|
}
|
|
|
|
// TODO: fix this
|
|
// this.stageInstance = data.stage_instance
|
|
|
|
// TODO: fix this
|
|
// this.targetApplication = data.target_application
|
|
|
|
if (data.target_type) {
|
|
this.targetType = data.target_type;
|
|
}
|
|
}
|
|
|
|
readonly session: Session;
|
|
guild?: InviteGuild;
|
|
approximateMemberCount?: number;
|
|
approximatePresenceCount?: number;
|
|
code: string;
|
|
expiresAt?: number;
|
|
inviter?: User;
|
|
targetUser?: User;
|
|
targeType?: TargetTypes;
|
|
}
|
|
|
|
export default Invite;
|