From 9b92f820595efdf8b1bfcc5e740b4a9401090220 Mon Sep 17 00:00:00 2001
From: MapleLeaf <19603573+itsMapleLeaf@users.noreply.github.com>
Date: Sun, 9 Jan 2022 02:58:47 -0600
Subject: [PATCH] add doc categories
---
.../reacord/library/core/component-event.ts | 18 ++++++++++++++++++
.../library/core/components/action-row.tsx | 4 ++--
.../reacord/library/core/components/button.tsx | 10 +++++++++-
.../library/core/components/embed-author.tsx | 6 ++++++
.../library/core/components/embed-field.tsx | 6 ++++++
.../library/core/components/embed-footer.tsx | 6 ++++++
.../library/core/components/embed-image.tsx | 6 ++++++
.../core/components/embed-thumbnail.tsx | 6 ++++++
.../library/core/components/embed-title.tsx | 6 ++++++
.../reacord/library/core/components/embed.tsx | 6 ++++++
.../reacord/library/core/components/link.tsx | 6 ++++++
.../reacord/library/core/components/option.tsx | 6 ++++++
.../reacord/library/core/components/select.tsx | 9 +++++++++
packages/reacord/library/core/instance.ts | 3 +++
.../reacord/library/core/reacord-discord-js.ts | 10 ++++++++++
.../reacord/library/core/reacord-tester.ts | 3 +++
packages/reacord/library/core/reacord.ts | 11 +++++++----
17 files changed, 115 insertions(+), 7 deletions(-)
diff --git a/packages/reacord/library/core/component-event.ts b/packages/reacord/library/core/component-event.ts
index 2b5873e..57dbefa 100644
--- a/packages/reacord/library/core/component-event.ts
+++ b/packages/reacord/library/core/component-event.ts
@@ -1,6 +1,9 @@
import type { ReactNode } from "react"
import type { ReacordInstance } from "./instance"
+/**
+ * @category Component Event
+ */
export type ComponentEvent = {
message: MessageInfo
channel: ChannelInfo
@@ -10,6 +13,9 @@ export type ComponentEvent = {
ephemeralReply(content?: ReactNode): ReacordInstance
}
+/**
+ * @category Component Event
+ */
export type ChannelInfo = {
id: string
name?: string
@@ -21,6 +27,9 @@ export type ChannelInfo = {
rateLimitPerUser?: number
}
+/**
+ * @category Component Event
+ */
export type MessageInfo = {
id: string
channelId: string
@@ -35,12 +44,18 @@ export type MessageInfo = {
mentions: string[]
}
+/**
+ * @category Component Event
+ */
export type GuildInfo = {
id: string
name: string
member: GuildMemberInfo
}
+/**
+ * @category Component Event
+ */
export type GuildMemberInfo = {
id: string
nick?: string
@@ -55,6 +70,9 @@ export type GuildMemberInfo = {
communicationDisabledUntil?: string
}
+/**
+ * @category Component Event
+ */
export type UserInfo = {
id: string
username: string
diff --git a/packages/reacord/library/core/components/action-row.tsx b/packages/reacord/library/core/components/action-row.tsx
index 0711fd7..225cb3b 100644
--- a/packages/reacord/library/core/components/action-row.tsx
+++ b/packages/reacord/library/core/components/action-row.tsx
@@ -6,7 +6,7 @@ import { Node } from "../../internal/node.js"
/**
* Props for an action row
- * @category Components
+ * @category Action Row
*/
export type ActionRowProps = {
children?: ReactNode
@@ -26,7 +26,7 @@ export type ActionRowProps = {
*
* ```
*
- * @category Components
+ * @category Action Row
* @see https://discord.com/developers/docs/interactions/message-components#action-rows
*/
export function ActionRow(props: ActionRowProps) {
diff --git a/packages/reacord/library/core/components/button.tsx b/packages/reacord/library/core/components/button.tsx
index 1fa8eeb..cb9da88 100644
--- a/packages/reacord/library/core/components/button.tsx
+++ b/packages/reacord/library/core/components/button.tsx
@@ -7,6 +7,9 @@ import { getNextActionRow } from "../../internal/message"
import { Node } from "../../internal/node.js"
import type { ComponentEvent } from "../component-event"
+/**
+ * @category Button
+ */
export type ButtonProps = {
label?: string
style?: "primary" | "secondary" | "success" | "danger"
@@ -14,9 +17,14 @@ export type ButtonProps = {
emoji?: string
onClick: (event: ButtonClickEvent) => void
}
-
+/**
+ * @category Button
+ */
export type ButtonClickEvent = ComponentEvent
+/**
+ * @category Button
+ */
export function Button(props: ButtonProps) {
return (
new ButtonNode(props)} />
diff --git a/packages/reacord/library/core/components/embed-author.tsx b/packages/reacord/library/core/components/embed-author.tsx
index 86828e4..ae4609a 100644
--- a/packages/reacord/library/core/components/embed-author.tsx
+++ b/packages/reacord/library/core/components/embed-author.tsx
@@ -3,6 +3,9 @@ import { ReacordElement } from "../../internal/element.js"
import { EmbedChildNode } from "./embed-child.js"
import type { EmbedOptions } from "./embed-options"
+/**
+ * @category Embed
+ */
export type EmbedAuthorProps = {
name?: string
children?: string
@@ -10,6 +13,9 @@ export type EmbedAuthorProps = {
iconUrl?: string
}
+/**
+ * @category Embed
+ */
export function EmbedAuthor(props: EmbedAuthorProps) {
return (
new EmbedNode(props)}>
diff --git a/packages/reacord/library/core/components/link.tsx b/packages/reacord/library/core/components/link.tsx
index 24f21ab..b43a680 100644
--- a/packages/reacord/library/core/components/link.tsx
+++ b/packages/reacord/library/core/components/link.tsx
@@ -4,6 +4,9 @@ import type { MessageOptions } from "../../internal/message"
import { getNextActionRow } from "../../internal/message"
import { Node } from "../../internal/node.js"
+/**
+ * @category Link
+ */
export type LinkProps = {
label?: string
children?: string
@@ -12,6 +15,9 @@ export type LinkProps = {
url: string
}
+/**
+ * @category Link
+ */
export function Link(props: LinkProps) {
return new LinkNode(props)} />
}
diff --git a/packages/reacord/library/core/components/option.tsx b/packages/reacord/library/core/components/option.tsx
index f4349b8..579cd52 100644
--- a/packages/reacord/library/core/components/option.tsx
+++ b/packages/reacord/library/core/components/option.tsx
@@ -2,6 +2,9 @@ import React from "react"
import { ReacordElement } from "../../internal/element"
import { OptionNode } from "./option-node"
+/**
+ * @category Select
+ */
export type OptionProps = {
label?: string
children?: string
@@ -10,6 +13,9 @@ export type OptionProps = {
emoji?: string
}
+/**
+ * @category Select
+ */
export function Option(props: OptionProps) {
return (
new OptionNode(props)} />
diff --git a/packages/reacord/library/core/components/select.tsx b/packages/reacord/library/core/components/select.tsx
index 4224a58..41ad14c 100644
--- a/packages/reacord/library/core/components/select.tsx
+++ b/packages/reacord/library/core/components/select.tsx
@@ -9,6 +9,9 @@ import { Node } from "../../internal/node.js"
import type { ComponentEvent } from "../component-event"
import { OptionNode } from "./option-node"
+/**
+ * @category Select
+ */
export type SelectProps = {
children?: ReactNode
value?: string
@@ -23,10 +26,16 @@ export type SelectProps = {
onChangeMultiple?: (values: string[], event: SelectChangeEvent) => void
}
+/**
+ * @category Select
+ */
export type SelectChangeEvent = ComponentEvent & {
values: string[]
}
+/**
+ * @category Select
+ */
export function Select(props: SelectProps) {
return (
new SelectNode(props)}>
diff --git a/packages/reacord/library/core/instance.ts b/packages/reacord/library/core/instance.ts
index 11baef5..4f30d50 100644
--- a/packages/reacord/library/core/instance.ts
+++ b/packages/reacord/library/core/instance.ts
@@ -1,5 +1,8 @@
import type { ReactNode } from "react"
+/**
+ * @category Core
+ */
export type ReacordInstance = {
render: (content: ReactNode) => void
deactivate: () => void
diff --git a/packages/reacord/library/core/reacord-discord-js.ts b/packages/reacord/library/core/reacord-discord-js.ts
index d9fd19d..3d67ea1 100644
--- a/packages/reacord/library/core/reacord-discord-js.ts
+++ b/packages/reacord/library/core/reacord-discord-js.ts
@@ -21,6 +21,10 @@ import type { ReacordInstance } from "./instance"
import type { ReacordConfig } from "./reacord"
import { Reacord } from "./reacord"
+/**
+ * The Reacord adapter for Discord.js.
+ * @category Core
+ */
export class ReacordDiscordJs extends Reacord {
constructor(private client: Discord.Client, config: ReacordConfig = {}) {
super(config)
@@ -34,6 +38,12 @@ export class ReacordDiscordJs extends Reacord {
})
}
+ /**
+ * Sends a message to a channel.
+ * @param channelId The ID of the channel to create a message in.
+ * @param initialContent The initial content of the message.
+ * @returns A Record instance.
+ */
override send(
channelId: string,
initialContent?: React.ReactNode,
diff --git a/packages/reacord/library/core/reacord-tester.ts b/packages/reacord/library/core/reacord-tester.ts
index ab16400..3ae9c4e 100644
--- a/packages/reacord/library/core/reacord-tester.ts
+++ b/packages/reacord/library/core/reacord-tester.ts
@@ -35,6 +35,9 @@ import { Reacord } from "./reacord"
const nextTickPromise = promisify(nextTick)
+/**
+ * A Record adapter for automated tests. WIP
+ */
export class ReacordTester extends Reacord {
private messageContainer = new Container()
diff --git a/packages/reacord/library/core/reacord.ts b/packages/reacord/library/core/reacord.ts
index aeabe4f..b1de60c 100644
--- a/packages/reacord/library/core/reacord.ts
+++ b/packages/reacord/library/core/reacord.ts
@@ -4,6 +4,9 @@ import { reconciler } from "../internal/reconciler.js"
import type { Renderer } from "../internal/renderers/renderer"
import type { ReacordInstance } from "./instance"
+/**
+ * @category Core
+ */
export type ReacordConfig = {
/**
* The max number of active instances.
@@ -12,10 +15,10 @@ export type ReacordConfig = {
maxInstances?: number
}
-export type ComponentInteractionListener = (
- interaction: ComponentInteraction,
-) => void
-
+/**
+ * The main Reacord class that other Reacord adapters should extend.
+ * Only use this directly if you're making [a custom adapter](/guides/custom-adapters).
+ */
export abstract class Reacord {
private renderers: Renderer[] = []