2020-10-22 15:50:47 +00:00
|
|
|
import { Client } from '../models/client.ts'
|
2020-10-31 12:33:34 +00:00
|
|
|
import { ChannelPayload } from '../types/channel.ts'
|
|
|
|
import { GuildPayload } from '../types/guild.ts'
|
|
|
|
import { InvitePayload } from '../types/invite.ts'
|
|
|
|
import { UserPayload } from '../types/user.ts'
|
2020-10-22 15:50:47 +00:00
|
|
|
import { Base } from './base.ts'
|
|
|
|
|
2020-10-23 16:11:00 +00:00
|
|
|
export class Invite extends Base {
|
2020-10-22 15:50:47 +00:00
|
|
|
code: string
|
2020-10-23 16:11:00 +00:00
|
|
|
guild?: GuildPayload
|
|
|
|
channel: ChannelPayload
|
|
|
|
inviter?: UserPayload
|
|
|
|
targetUser?: UserPayload
|
|
|
|
targetUserType?: number
|
|
|
|
approximatePresenceCount?: number
|
|
|
|
approximateMemberCount?: number
|
2020-10-23 03:19:40 +00:00
|
|
|
|
2020-10-25 17:03:53 +00:00
|
|
|
get link (): string {
|
2020-10-23 16:11:00 +00:00
|
|
|
return `https://discord.gg/${this.code}`
|
2020-10-23 03:19:40 +00:00
|
|
|
}
|
|
|
|
|
2020-10-22 15:50:47 +00:00
|
|
|
constructor (client: Client, data: InvitePayload) {
|
|
|
|
super(client)
|
|
|
|
this.code = data.code
|
|
|
|
this.guild = data.guild
|
|
|
|
this.channel = data.channel
|
|
|
|
this.inviter = data.inviter
|
2020-10-23 16:11:00 +00:00
|
|
|
this.targetUser = data.target_user
|
|
|
|
this.targetUserType = data.target_user_type
|
|
|
|
this.approximateMemberCount = data.approximate_member_count
|
|
|
|
this.approximatePresenceCount = data.approximate_presence_count
|
2020-10-22 15:50:47 +00:00
|
|
|
}
|
2020-10-29 14:43:27 +00:00
|
|
|
|
2020-10-30 14:51:40 +00:00
|
|
|
protected readFromData (data: InvitePayload): void {
|
2020-10-29 14:43:27 +00:00
|
|
|
super.readFromData(data)
|
|
|
|
this.code = data.code ?? this.code
|
|
|
|
this.guild = data.guild ?? this.guild
|
|
|
|
this.channel = data.channel ?? this.channel
|
|
|
|
this.inviter = data.inviter ?? this.inviter
|
|
|
|
this.targetUser = data.target_user ?? this.targetUser
|
|
|
|
this.targetUserType = data.target_user_type ?? this.targetUserType
|
|
|
|
this.approximateMemberCount =
|
|
|
|
data.approximate_member_count ?? this.approximateMemberCount
|
|
|
|
this.approximatePresenceCount =
|
|
|
|
data.approximate_presence_count ?? this.approximatePresenceCount
|
|
|
|
}
|
2020-10-22 15:50:47 +00:00
|
|
|
}
|