From 9c60c24dca9381f50ee0007cb2f522e98aebdbdb Mon Sep 17 00:00:00 2001 From: itsMapleLeaf <19603573+itsMapleLeaf@users.noreply.github.com> Date: Fri, 5 Aug 2022 11:44:46 -0500 Subject: [PATCH] message payload tweaks --- .../reacord/library/make-message-update-payload.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/reacord/library/make-message-update-payload.ts b/packages/reacord/library/make-message-update-payload.ts index 2881175..8175d60 100644 --- a/packages/reacord/library/make-message-update-payload.ts +++ b/packages/reacord/library/make-message-update-payload.ts @@ -30,7 +30,7 @@ import { import { SelectNode } from "./react/select" export type MessageUpdatePayload = { - content: string + content: string | null embeds: APIEmbed[] components: Array< APIActionRowComponent @@ -39,7 +39,8 @@ export type MessageUpdatePayload = { export function makeMessageUpdatePayload(root: Node): MessageUpdatePayload { return { - content: root.extractText(), + // eslint-disable-next-line unicorn/no-null + content: root.extractText() || null, embeds: makeEmbeds(root), components: makeActionRows(root), } @@ -167,7 +168,7 @@ function makeActionRows(root: Node) { type: ComponentType.Button, custom_id: node.customId, label: node.extractText(Number.POSITIVE_INFINITY), - emoji: { name: node.props.emoji }, + emoji: node.props.emoji ? { name: node.props.emoji } : undefined, style: translateButtonStyle(node.props.style ?? "secondary"), disabled: node.props.disabled, }) @@ -201,7 +202,9 @@ function makeActionRows(root: Node) { const options = [...node.children] .flatMap((child) => (child instanceof OptionNode ? child : [])) .map((child) => ({ - label: child.findInstanceOf(OptionLabelNode)?.extractText() ?? "", + label: + child.findInstanceOf(OptionLabelNode)?.extractText() || + child.props.value, description: child .findInstanceOf(OptionDescriptionNode) ?.extractText(),