Add invite type (#3614)

This commit is contained in:
Fleny
2024-07-06 16:30:05 -05:00
committed by GitHub
parent 9cca689688
commit 9cea65f761
3 changed files with 14 additions and 1 deletions
+2
View File
@@ -317,6 +317,7 @@ export interface Transformers {
context: boolean
}
invite: {
type: boolean
channelId: boolean
code: boolean
createdAt: boolean
@@ -936,6 +937,7 @@ export function createTransformers(options: Partial<Transformers>, opts?: Create
context: opts?.defaultDesiredPropertiesValue ?? false,
},
invite: {
type: opts?.defaultDesiredPropertiesValue ?? false,
channelId: opts?.defaultDesiredPropertiesValue ?? false,
code: opts?.defaultDesiredPropertiesValue ?? false,
createdAt: opts?.defaultDesiredPropertiesValue ?? false,
+4 -1
View File
@@ -1,4 +1,4 @@
import type { DiscordApplication, DiscordInviteCreate, DiscordInviteMetadata } from '@discordeno/types'
import type { DiscordApplication, DiscordInviteCreate, DiscordInviteMetadata, DiscordInviteType } from '@discordeno/types'
import { isInviteWithMetadata, type Application, type Bot, type ScheduledEvent, type User } from '../index.js'
import type { InviteStageInstance } from './stageInviteInstance.js'
@@ -6,6 +6,7 @@ export function transformInvite(bot: Bot, payload: { invite: DiscordInviteCreate
const props = bot.transformers.desiredProperties.invite
const invite = {} as Invite
if (props.type && 'type' in payload.invite) invite.type = payload.invite.type
if (props.code && payload.invite.code) invite.code = payload.invite.code
if (props.createdAt && payload.invite.created_at) invite.createdAt = Date.parse(payload.invite.created_at)
if (props.inviter && payload.invite.inviter) invite.inviter = bot.transformers.user(bot, payload.invite.inviter)
@@ -48,6 +49,8 @@ export function transformInvite(bot: Bot, payload: { invite: DiscordInviteCreate
}
export interface Invite {
/** The type of invite */
type: DiscordInviteType
/** The channel the invite is for */
channelId: bigint
/** The unique invite code */