From 9cea65f7613b8abccff266130ecc6a07e339e3e8 Mon Sep 17 00:00:00 2001 From: Fleny Date: Sat, 6 Jul 2024 23:30:05 +0200 Subject: [PATCH] Add invite type (#3614) --- packages/bot/src/transformers.ts | 2 ++ packages/bot/src/transformers/invite.ts | 5 ++++- packages/types/src/discord.ts | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/bot/src/transformers.ts b/packages/bot/src/transformers.ts index 6140ff087..4919a573a 100644 --- a/packages/bot/src/transformers.ts +++ b/packages/bot/src/transformers.ts @@ -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, opts?: Create context: opts?.defaultDesiredPropertiesValue ?? false, }, invite: { + type: opts?.defaultDesiredPropertiesValue ?? false, channelId: opts?.defaultDesiredPropertiesValue ?? false, code: opts?.defaultDesiredPropertiesValue ?? false, createdAt: opts?.defaultDesiredPropertiesValue ?? false, diff --git a/packages/bot/src/transformers/invite.ts b/packages/bot/src/transformers/invite.ts index 68040c90a..b50cdc5bb 100644 --- a/packages/bot/src/transformers/invite.ts +++ b/packages/bot/src/transformers/invite.ts @@ -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 */ diff --git a/packages/types/src/discord.ts b/packages/types/src/discord.ts index 481838e59..abdb1ba3e 100644 --- a/packages/types/src/discord.ts +++ b/packages/types/src/discord.ts @@ -2284,6 +2284,8 @@ export interface DiscordInviteMetadata extends DiscordInvite { /** https://discord.com/developers/docs/resources/invite#invite-object */ export interface DiscordInvite { + /** The type of invite */ + type: DiscordInviteType /** The invite code (unique Id) */ code: string /** The guild this invite is for */ @@ -2310,6 +2312,12 @@ export interface DiscordInvite { guild_scheduled_event?: DiscordScheduledEvent } +export enum DiscordInviteType { + Guild, + GroupDm, + Friend, +} + export interface DiscordInviteStageInstance { /** The members speaking in the Stage */ members: Array>