From a8090ef798710d0e11e76ec38284ee4a34b90986 Mon Sep 17 00:00:00 2001 From: Zomatree <39768508+Zomatree@users.noreply.github.com> Date: Fri, 14 Jan 2022 22:47:13 +0000 Subject: [PATCH] feat: add sendable embeds (#17) --- src/routes/channels.ts | 16 +++++++++++++++- types/Channels.ts | 27 ++++++++++++++++++++++++++- types/January.ts | 6 ++---- 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/src/routes/channels.ts b/src/routes/channels.ts index 51a3bf0..cb7081e 100644 --- a/src/routes/channels.ts +++ b/src/routes/channels.ts @@ -169,7 +169,7 @@ resource('/channels/:channel/messages', { ...channelParams, ...await body("Message to be sent.", schema` import type { Id, AutumnId } from './_common'; - import type { Masquerade } from './Channels'; + import type { Masquerade, SendableEmbed } from './Channels'; interface ${'SendMessage'} { /** @@ -184,6 +184,13 @@ resource('/channels/:channel/messages', { */ attachments?: AutumnId[]; + /** + * Embeds to include in the message + * @minLength 1 + * @maxLength 10 + */ + embeds?: SendableEmbed[]; + /** * Messages to reply to. */ @@ -285,6 +292,13 @@ resource('/channels/:channel/messages/:message', { * @maxLength 2000 */ content: string; + + /** + * Embeds to include in the message. + * @minLength 0 + * @maxLength 10 + */ + embeds?: SendableEmbed[]; } `), ...await noContent("Message was changed.") diff --git a/types/Channels.ts b/types/Channels.ts index c289f69..04cd992 100644 --- a/types/Channels.ts +++ b/types/Channels.ts @@ -1,6 +1,6 @@ import type { Attachment } from "./Autumn" import type { Id, Nonce } from "./_common" -import type { Embed } from "./January" +import type { JanuaryEmbed } from "./January" /** * Saved Messages channel has only one participant, the user who created it. @@ -226,3 +226,28 @@ export type SystemMessage = | { type: "channel_renamed"; name: string, by: Id } | { type: "channel_description_changed"; by: Id } | { type: "channel_icon_changed"; by: Id }; + +export type TextEmbed = { + type: "Text", + + icon_url?: string, + url?: string, + title?: string, + description?: string, + media?: Attachment, + colour?: string +} + +export type Embed = TextEmbed | JanuaryEmbed | { type: "None" } + +// better name? +export type SendableEmbed = { + type: "Text", + + icon_url?: string, + url?: string, + title?: string, + description?: string, + media?: string, + colour?: string +} diff --git a/types/January.ts b/types/January.ts index 8681037..4ba32fa 100644 --- a/types/January.ts +++ b/types/January.ts @@ -35,12 +35,10 @@ export type EmbedSpecial = ( ) /** - * Message embed + * Message url embed */ -export type Embed = ( +export type JanuaryEmbed = ( { - type: 'None' - } | { type: 'Website' url?: string