Files
discordeno/transformers/attachment.ts
LTS20050703 3518ed1e18 feat: add limit for attachment description (#2418)
* add limit for attachment description

* bot.transformers.reverse.attachment

* plugins/permissions: validate attachments
2022-09-03 12:35:41 -04:00

23 lines
732 B
TypeScript

import { Bot } from "../bot.ts";
import { DiscordAttachment } from "../types/discord.ts";
import { Optionalize } from "../types/shared.ts";
export function transformAttachment(bot: Bot, payload: DiscordAttachment) {
const attachment = {
id: bot.transformers.snowflake(payload.id),
filename: payload.filename,
contentType: payload.content_type,
size: payload.size,
url: payload.url,
proxyUrl: payload.proxy_url,
height: payload.height ?? undefined,
width: payload.width ?? undefined,
ephemeral: payload.ephemeral,
description: payload.description,
};
return attachment as Optionalize<typeof attachment>;
}
export interface Attachment extends ReturnType<typeof transformAttachment> {}