Files
discordeno/plugins/bot/transformers/attachment.ts
Skillz4Killz ffe7cdbc6f feat: base plugin lib idea (#2308)
* feat: base plugin lib idea

* fix: stuff

* fmt

* fix: imports and exports

* fix: errors & tests

* fix: remove logs
2022-06-18 18:46:37 -04:00

21 lines
648 B
TypeScript

import { Bot } from "../bot.ts";
import { DiscordAttachment, Optionalize } from "../deps.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,
};
return attachment as Optionalize<typeof attachment>;
}
export interface Attachment extends ReturnType<typeof transformAttachment> {}