mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-01 08:20:08 +00:00
Merge pull request #1945 from discordeno/attachments
feat: attachment option
This commit is contained in:
@@ -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[];
|
||||
|
||||
@@ -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>;
|
||||
}
|
||||
|
||||
@@ -10,4 +10,5 @@ export enum ApplicationCommandOptionTypes {
|
||||
Role,
|
||||
Mentionable,
|
||||
Number,
|
||||
Attachment
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user