some docs

This commit is contained in:
MapleLeaf
2021-12-26 15:05:58 -06:00
parent 7efc7d53c9
commit 51bbdea73e
30 changed files with 2623 additions and 48 deletions

View File

@@ -1,9 +1,15 @@
import type { CommandInteraction, ComponentInteraction } from "../interaction"
export type Adapter<InteractionInit> = {
/**
* @internal
*/
addComponentInteractionListener(
listener: (interaction: ComponentInteraction) => void,
): void
/**
* @internal
*/
createCommandInteraction(interactionInfo: InteractionInit): CommandInteraction
}

View File

@@ -8,6 +8,9 @@ import type { Adapter } from "./adapter"
export class DiscordJsAdapter implements Adapter<Discord.CommandInteraction> {
constructor(private client: Discord.Client) {}
/**
* @internal
*/
addComponentInteractionListener(
listener: (interaction: ComponentInteraction) => void,
) {
@@ -18,6 +21,9 @@ export class DiscordJsAdapter implements Adapter<Discord.CommandInteraction> {
})
}
/**
* @internal
*/
// eslint-disable-next-line class-methods-use-this
createCommandInteraction(
interaction: Discord.CommandInteraction,

View File

@@ -2,7 +2,7 @@ import { nanoid } from "nanoid"
import React from "react"
import { last } from "../helpers/last.js"
import { ReacordElement } from "./element.js"
import type { ButtonInteraction, ComponentInteraction } from "./interaction"
import type { ComponentInteraction } from "./interaction"
import type { MessageOptions } from "./message"
import { Node } from "./node.js"
@@ -11,9 +11,11 @@ export type ButtonProps = {
style?: "primary" | "secondary" | "success" | "danger"
disabled?: boolean
emoji?: string
onClick: (interaction: ButtonInteraction) => void
onClick: (event: ButtonClickEvent) => void
}
export type ButtonClickEvent = {}
export function Button(props: ButtonProps) {
return (
<ReacordElement props={props} createNode={() => new ButtonNode(props)} />

View File

@@ -1,19 +1,8 @@
export type EmbedOptions = {
title?: string
description?: string
url?: string
timestamp?: string
color?: number
fields?: EmbedFieldOptions[]
author?: { name: string; url?: string; icon_url?: string }
thumbnail?: { url: string }
image?: { url: string }
video?: { url: string }
footer?: { text: string; icon_url?: string }
}
import type { Except, SnakeCasedPropertiesDeep } from "type-fest"
import type { EmbedProps } from "./embed"
export type EmbedFieldOptions = {
name: string
value: string
inline?: boolean
}
export type EmbedOptions = SnakeCasedPropertiesDeep<
Except<EmbedProps, "timestamp" | "children"> & {
timestamp?: string
}
>

View File

@@ -1,5 +1,4 @@
import React from "react"
import type { CamelCasedPropertiesDeep } from "type-fest"
import { snakeCaseDeep } from "../../helpers/convert-object-property-case"
import { omit } from "../../helpers/omit"
import { ReacordElement } from "../element.js"
@@ -8,10 +7,17 @@ import { Node } from "../node.js"
import { EmbedChildNode } from "./embed-child.js"
import type { EmbedOptions } from "./embed-options"
export type EmbedProps = Omit<
CamelCasedPropertiesDeep<EmbedOptions>,
"timestamp"
> & {
export type EmbedProps = {
title?: string
description?: string
url?: string
color?: number
fields?: Array<{ name: string; value: string; inline?: boolean }>
author?: { name: string; url?: string; iconUrl?: string }
thumbnail?: { url: string }
image?: { url: string }
video?: { url: string }
footer?: { text: string; iconUrl?: string }
timestamp?: string | number | Date
children?: React.ReactNode
}

View File

@@ -1,6 +1,5 @@
export * from "./adapter/adapter"
export * from "./adapter/discord-js-adapter"
export * from "./adapter/test-adapter"
export * from "./button"
export * from "./embed/embed"
export * from "./embed/embed-author"
@@ -9,7 +8,5 @@ export * from "./embed/embed-footer"
export * from "./embed/embed-image"
export * from "./embed/embed-thumbnail"
export * from "./embed/embed-title"
export * from "./interaction"
export * from "./link"
export * from "./message"
export * from "./reacord"

1
library/testing.ts Normal file
View File

@@ -0,0 +1 @@
export * from "./adapter/test-adapter"