Merge pull request #1945 from discordeno/attachments

feat: attachment option
This commit is contained in:
Skillz4Killz
2022-02-01 12:08:49 -05:00
committed by GitHub
3 changed files with 18 additions and 4 deletions

View File

@@ -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<bigint, DiscordenoMember>;
roles?: Collection<bigint, DiscordenoRole>;
channels?: Collection<bigint, { id: bigint; name: string; type: ChannelTypes; permissions: bigint }>;
attachments?: Collection<bigint, DiscordenoAttachment>;
} = {};
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<Attachment>)];
})
);
}
return transformed;
}
@@ -182,6 +190,8 @@ export interface DiscordenoInteraction {
permissions: bigint;
}
>;
/** The Ids and attachments objects */
attachments?: Collection<bigint, DiscordenoAttachment>;
};
/** The params + values from the user */
options?: InteractionDataOption[];

View File

@@ -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<string, Role>;
/** The Ids and partial Channel objects */
channels?: Record<string, Pick<Channel, "id" | "name" | "type" | "permissions">>;
/** The Ids and attachments objects */
attachments?: Record<string, Attachment>;
}

View File

@@ -10,4 +10,5 @@ export enum ApplicationCommandOptionTypes {
Role,
Mentionable,
Number,
Attachment
}