add doc categories
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 = {
|
||||
* <Button onClick={handleSecond}>Second</Button>
|
||||
* ```
|
||||
*
|
||||
* @category Components
|
||||
* @category Action Row
|
||||
* @see https://discord.com/developers/docs/interactions/message-components#action-rows
|
||||
*/
|
||||
export function ActionRow(props: ActionRowProps) {
|
||||
|
||||
@@ -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 (
|
||||
<ReacordElement props={props} createNode={() => new ButtonNode(props)} />
|
||||
|
||||
@@ -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 (
|
||||
<ReacordElement
|
||||
|
||||
@@ -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 EmbedFieldProps = {
|
||||
name: string
|
||||
value?: string
|
||||
@@ -10,6 +13,9 @@ export type EmbedFieldProps = {
|
||||
children?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* @category Embed
|
||||
*/
|
||||
export function EmbedField(props: EmbedFieldProps) {
|
||||
return (
|
||||
<ReacordElement
|
||||
|
||||
@@ -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 EmbedFooterProps = {
|
||||
text?: string
|
||||
children?: string
|
||||
@@ -10,6 +13,9 @@ export type EmbedFooterProps = {
|
||||
timestamp?: string | number | Date
|
||||
}
|
||||
|
||||
/**
|
||||
* @category Embed
|
||||
*/
|
||||
export function EmbedFooter(props: EmbedFooterProps) {
|
||||
return (
|
||||
<ReacordElement
|
||||
|
||||
@@ -3,10 +3,16 @@ import { ReacordElement } from "../../internal/element.js"
|
||||
import { EmbedChildNode } from "./embed-child.js"
|
||||
import type { EmbedOptions } from "./embed-options"
|
||||
|
||||
/**
|
||||
* @category Embed
|
||||
*/
|
||||
export type EmbedImageProps = {
|
||||
url: string
|
||||
}
|
||||
|
||||
/**
|
||||
* @category Embed
|
||||
*/
|
||||
export function EmbedImage(props: EmbedImageProps) {
|
||||
return (
|
||||
<ReacordElement
|
||||
|
||||
@@ -3,10 +3,16 @@ import { ReacordElement } from "../../internal/element.js"
|
||||
import { EmbedChildNode } from "./embed-child.js"
|
||||
import type { EmbedOptions } from "./embed-options"
|
||||
|
||||
/**
|
||||
* @category Embed
|
||||
*/
|
||||
export type EmbedThumbnailProps = {
|
||||
url: string
|
||||
}
|
||||
|
||||
/**
|
||||
* @category Embed
|
||||
*/
|
||||
export function EmbedThumbnail(props: EmbedThumbnailProps) {
|
||||
return (
|
||||
<ReacordElement
|
||||
|
||||
@@ -3,11 +3,17 @@ import { ReacordElement } from "../../internal/element.js"
|
||||
import { EmbedChildNode } from "./embed-child.js"
|
||||
import type { EmbedOptions } from "./embed-options"
|
||||
|
||||
/**
|
||||
* @category Embed
|
||||
*/
|
||||
export type EmbedTitleProps = {
|
||||
children: string
|
||||
url?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* @category Embed
|
||||
*/
|
||||
export function EmbedTitle(props: EmbedTitleProps) {
|
||||
return (
|
||||
<ReacordElement
|
||||
|
||||
@@ -8,6 +8,9 @@ import { TextNode } from "../../internal/text-node"
|
||||
import { EmbedChildNode } from "./embed-child.js"
|
||||
import type { EmbedOptions } from "./embed-options"
|
||||
|
||||
/**
|
||||
* @category Embed
|
||||
*/
|
||||
export type EmbedProps = {
|
||||
title?: string
|
||||
description?: string
|
||||
@@ -23,6 +26,9 @@ export type EmbedProps = {
|
||||
children?: React.ReactNode
|
||||
}
|
||||
|
||||
/**
|
||||
* @category Embed
|
||||
*/
|
||||
export function Embed(props: EmbedProps) {
|
||||
return (
|
||||
<ReacordElement props={props} createNode={() => new EmbedNode(props)}>
|
||||
|
||||
@@ -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 <ReacordElement props={props} createNode={() => new LinkNode(props)} />
|
||||
}
|
||||
|
||||
@@ -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 (
|
||||
<ReacordElement props={props} createNode={() => new OptionNode(props)} />
|
||||
|
||||
@@ -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 (
|
||||
<ReacordElement props={props} createNode={() => new SelectNode(props)}>
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import type { ReactNode } from "react"
|
||||
|
||||
/**
|
||||
* @category Core
|
||||
*/
|
||||
export type ReacordInstance = {
|
||||
render: (content: ReactNode) => void
|
||||
deactivate: () => void
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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<TestMessage>()
|
||||
|
||||
|
||||
@@ -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[] = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user