TODO done: targetApplication implemented & Minor changes

This commit is contained in:
Nicolás Serna 2022-07-08 22:15:03 -03:00
parent 4177ab162d
commit a7317a0a3c

View File

@ -8,6 +8,7 @@ import type {
ScheduledEventEntityType, ScheduledEventEntityType,
ScheduledEventPrivacyLevel, ScheduledEventPrivacyLevel,
ScheduledEventStatus, ScheduledEventStatus,
DiscordApplication
} from "../../discordeno/mod.ts"; } from "../../discordeno/mod.ts";
import { TargetTypes } from "../../discordeno/mod.ts"; import { TargetTypes } from "../../discordeno/mod.ts";
import { GuildChannel } from "./channels.ts"; import { GuildChannel } from "./channels.ts";
@ -15,6 +16,7 @@ import { Member } from "./Member.ts";
import InviteGuild from "./guilds/InviteGuild.ts"; import InviteGuild from "./guilds/InviteGuild.ts";
import User from "./User.ts"; import User from "./User.ts";
import Guild from "./guilds/Guild.ts"; import Guild from "./guilds/Guild.ts";
import Application from "./Application.ts";
export interface InviteStageInstance { export interface InviteStageInstance {
/** The members speaking in the Stage */ /** The members speaking in the Stage */
@ -53,29 +55,21 @@ export class Invite {
constructor(session: Session, data: DiscordInvite) { constructor(session: Session, data: DiscordInvite) {
this.session = session; this.session = session;
if (data.guild) { this.guild = data.guild ? new InviteGuild(session, data.guild) : undefined;
this.guild = new InviteGuild(session, data.guild); this.approximateMemberCount = data.approximate_member_count ? data.approximate_member_count : undefined;
} this.approximatePresenceCount = data.approximate_presence_count ? data.approximate_presence_count : undefined;
this.code = data.code;
if (data.approximate_member_count) { this.expiresAt = data.expires_at ? Number.parseInt(data.expires_at) : undefined;
this.approximateMemberCount = data.approximate_member_count; this.inviter = data.inviter ? new User(session, data.inviter) : undefined;
} this.targetUser = data.target_user ? new User(session, data.target_user) : undefined;
this.targetApplication = data.target_application ? new Application(session, data.target_application as DiscordApplication) : undefined;
if (data.approximate_presence_count) { this.targetType = data.target_type;
this.approximatePresenceCount = data.approximate_presence_count;
}
if (data.channel) { if (data.channel) {
const guildId = (data.guild && data.guild?.id) ? data.guild.id : ""; const guildId = (data.guild && data.guild?.id) ? data.guild.id : "";
this.channel = new GuildChannel(session, data.channel as DiscordChannel, guildId); this.channel = new GuildChannel(session, data.channel as DiscordChannel, guildId);
} }
this.code = data.code;
if (data.expires_at) {
this.expiresAt = Number.parseInt(data.expires_at);
}
if (data.guild_scheduled_event) { if (data.guild_scheduled_event) {
this.guildScheduledEvent = { this.guildScheduledEvent = {
id: data.guild_scheduled_event.id, id: data.guild_scheduled_event.id,
@ -105,14 +99,6 @@ export class Invite {
}; };
} }
if (data.inviter) {
this.inviter = new User(session, data.inviter);
}
if (data.target_user) {
this.targetUser = new User(session, data.target_user);
}
if (data.stage_instance) { if (data.stage_instance) {
const guildId = (data.guild && data.guild?.id) ? data.guild.id : ""; const guildId = (data.guild && data.guild?.id) ? data.guild.id : "";
this.stageInstance = { this.stageInstance = {
@ -124,13 +110,6 @@ export class Invite {
topic: data.stage_instance.topic, topic: data.stage_instance.topic,
}; };
} }
// TODO: create Application structure
// this.targetApplication = data.target_application
if (data.target_type) {
this.targetType = data.target_type;
}
} }
readonly session: Session; readonly session: Session;
@ -145,8 +124,7 @@ export class Invite {
channel?: Partial<GuildChannel>; channel?: Partial<GuildChannel>;
stageInstance?: InviteStageInstance; stageInstance?: InviteStageInstance;
guildScheduledEvent?: InviteScheduledEvent; guildScheduledEvent?: InviteScheduledEvent;
// TODO: create Application structure targetApplication?: Partial<Application>
// targetApplication?: Partial<Application>
async delete(): Promise<Invite> { async delete(): Promise<Invite> {
await Guild.prototype.deleteInvite.call(this.guild, this.code); await Guild.prototype.deleteInvite.call(this.guild, this.code);