From 0e4caf1c4731a3d979b8855350a28894051e6cc5 Mon Sep 17 00:00:00 2001 From: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> Date: Fri, 28 Jan 2022 02:04:35 +0000 Subject: [PATCH] feat: attachment option --- src/transformers/interaction.ts | 18 ++++++++++++++---- ...pplicationCommandInteractionDataResolved.ts | 3 +++ .../commands/applicationCommandOptionTypes.ts | 1 + 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/transformers/interaction.ts b/src/transformers/interaction.ts index 402fbdee0..58054978b 100644 --- a/src/transformers/interaction.ts +++ b/src/transformers/interaction.ts @@ -1,19 +1,17 @@ import { Bot } from "../bot.ts"; import { ChannelTypes } from "../types/channels/channelTypes.ts"; import { - InteractionData, - ButtonData, InteractionTypes, Interaction, - SelectMenuData, InteractionDataResolved, MessageComponentTypes, InteractionDataOption, MessageComponents, + Attachment, } from "../types/mod.ts"; import { SnakeCasedPropertiesDeep } from "../types/util.ts"; import { Collection } from "../util/collection.ts"; -import { DiscordenoChannel } from "./channel.ts"; +import { DiscordenoAttachment } from "./attachment.ts"; import { DiscordenoMember, DiscordenoUser } from "./member.ts"; import { DiscordenoMessage } from "./message.ts"; import { DiscordenoRole } from "./role.ts"; @@ -68,6 +66,7 @@ export function transformInteractionDataResolved( members?: Collection; roles?: Collection; channels?: Collection; + attachments?: Collection; } = {}; if (resolved.messages) { @@ -124,6 +123,15 @@ export function transformInteractionDataResolved( ); } + if (resolved.attachments) { + transformed.attachments = new Collection( + Object.entries(resolved.attachments).map(([key, value]) => { + const id = bot.transformers.snowflake(key); + return [id, bot.transformers.attachment(bot, value as SnakeCasedPropertiesDeep)]; + }) + ); + } + return transformed; } @@ -182,6 +190,8 @@ export interface DiscordenoInteraction { permissions: bigint; } >; + /** The Ids and attachments objects */ + attachments?: Collection; }; /** The params + values from the user */ options?: InteractionDataOption[]; diff --git a/src/types/interactions/commands/applicationCommandInteractionDataResolved.ts b/src/types/interactions/commands/applicationCommandInteractionDataResolved.ts index bd74a084e..771781d6e 100644 --- a/src/types/interactions/commands/applicationCommandInteractionDataResolved.ts +++ b/src/types/interactions/commands/applicationCommandInteractionDataResolved.ts @@ -1,4 +1,5 @@ import { Channel } from "../../channels/channel.ts"; +import { Attachment } from "../../messages/attachment.ts"; import { Message } from "../../messages/message.ts"; import { Role } from "../../permissions/role.ts"; import { User } from "../../users/user.ts"; @@ -15,4 +16,6 @@ export interface InteractionDataResolved { roles?: Record; /** The Ids and partial Channel objects */ channels?: Record>; + /** The Ids and attachments objects */ + attachments?: Record; } diff --git a/src/types/interactions/commands/applicationCommandOptionTypes.ts b/src/types/interactions/commands/applicationCommandOptionTypes.ts index 2335ff019..de45d0f0e 100644 --- a/src/types/interactions/commands/applicationCommandOptionTypes.ts +++ b/src/types/interactions/commands/applicationCommandOptionTypes.ts @@ -10,4 +10,5 @@ export enum ApplicationCommandOptionTypes { Role, Mentionable, Number, + Attachment }