add doc categories
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
import type { ReactNode } from "react"
|
import type { ReactNode } from "react"
|
||||||
import type { ReacordInstance } from "./instance"
|
import type { ReacordInstance } from "./instance"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Component Event
|
||||||
|
*/
|
||||||
export type ComponentEvent = {
|
export type ComponentEvent = {
|
||||||
message: MessageInfo
|
message: MessageInfo
|
||||||
channel: ChannelInfo
|
channel: ChannelInfo
|
||||||
@@ -10,6 +13,9 @@ export type ComponentEvent = {
|
|||||||
ephemeralReply(content?: ReactNode): ReacordInstance
|
ephemeralReply(content?: ReactNode): ReacordInstance
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Component Event
|
||||||
|
*/
|
||||||
export type ChannelInfo = {
|
export type ChannelInfo = {
|
||||||
id: string
|
id: string
|
||||||
name?: string
|
name?: string
|
||||||
@@ -21,6 +27,9 @@ export type ChannelInfo = {
|
|||||||
rateLimitPerUser?: number
|
rateLimitPerUser?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Component Event
|
||||||
|
*/
|
||||||
export type MessageInfo = {
|
export type MessageInfo = {
|
||||||
id: string
|
id: string
|
||||||
channelId: string
|
channelId: string
|
||||||
@@ -35,12 +44,18 @@ export type MessageInfo = {
|
|||||||
mentions: string[]
|
mentions: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Component Event
|
||||||
|
*/
|
||||||
export type GuildInfo = {
|
export type GuildInfo = {
|
||||||
id: string
|
id: string
|
||||||
name: string
|
name: string
|
||||||
member: GuildMemberInfo
|
member: GuildMemberInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Component Event
|
||||||
|
*/
|
||||||
export type GuildMemberInfo = {
|
export type GuildMemberInfo = {
|
||||||
id: string
|
id: string
|
||||||
nick?: string
|
nick?: string
|
||||||
@@ -55,6 +70,9 @@ export type GuildMemberInfo = {
|
|||||||
communicationDisabledUntil?: string
|
communicationDisabledUntil?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Component Event
|
||||||
|
*/
|
||||||
export type UserInfo = {
|
export type UserInfo = {
|
||||||
id: string
|
id: string
|
||||||
username: string
|
username: string
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { Node } from "../../internal/node.js"
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Props for an action row
|
* Props for an action row
|
||||||
* @category Components
|
* @category Action Row
|
||||||
*/
|
*/
|
||||||
export type ActionRowProps = {
|
export type ActionRowProps = {
|
||||||
children?: ReactNode
|
children?: ReactNode
|
||||||
@@ -26,7 +26,7 @@ export type ActionRowProps = {
|
|||||||
* <Button onClick={handleSecond}>Second</Button>
|
* <Button onClick={handleSecond}>Second</Button>
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @category Components
|
* @category Action Row
|
||||||
* @see https://discord.com/developers/docs/interactions/message-components#action-rows
|
* @see https://discord.com/developers/docs/interactions/message-components#action-rows
|
||||||
*/
|
*/
|
||||||
export function ActionRow(props: ActionRowProps) {
|
export function ActionRow(props: ActionRowProps) {
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import { getNextActionRow } from "../../internal/message"
|
|||||||
import { Node } from "../../internal/node.js"
|
import { Node } from "../../internal/node.js"
|
||||||
import type { ComponentEvent } from "../component-event"
|
import type { ComponentEvent } from "../component-event"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Button
|
||||||
|
*/
|
||||||
export type ButtonProps = {
|
export type ButtonProps = {
|
||||||
label?: string
|
label?: string
|
||||||
style?: "primary" | "secondary" | "success" | "danger"
|
style?: "primary" | "secondary" | "success" | "danger"
|
||||||
@@ -14,9 +17,14 @@ export type ButtonProps = {
|
|||||||
emoji?: string
|
emoji?: string
|
||||||
onClick: (event: ButtonClickEvent) => void
|
onClick: (event: ButtonClickEvent) => void
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @category Button
|
||||||
|
*/
|
||||||
export type ButtonClickEvent = ComponentEvent
|
export type ButtonClickEvent = ComponentEvent
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Button
|
||||||
|
*/
|
||||||
export function Button(props: ButtonProps) {
|
export function Button(props: ButtonProps) {
|
||||||
return (
|
return (
|
||||||
<ReacordElement props={props} createNode={() => new ButtonNode(props)} />
|
<ReacordElement props={props} createNode={() => new ButtonNode(props)} />
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ import { ReacordElement } from "../../internal/element.js"
|
|||||||
import { EmbedChildNode } from "./embed-child.js"
|
import { EmbedChildNode } from "./embed-child.js"
|
||||||
import type { EmbedOptions } from "./embed-options"
|
import type { EmbedOptions } from "./embed-options"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Embed
|
||||||
|
*/
|
||||||
export type EmbedAuthorProps = {
|
export type EmbedAuthorProps = {
|
||||||
name?: string
|
name?: string
|
||||||
children?: string
|
children?: string
|
||||||
@@ -10,6 +13,9 @@ export type EmbedAuthorProps = {
|
|||||||
iconUrl?: string
|
iconUrl?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Embed
|
||||||
|
*/
|
||||||
export function EmbedAuthor(props: EmbedAuthorProps) {
|
export function EmbedAuthor(props: EmbedAuthorProps) {
|
||||||
return (
|
return (
|
||||||
<ReacordElement
|
<ReacordElement
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ import { ReacordElement } from "../../internal/element.js"
|
|||||||
import { EmbedChildNode } from "./embed-child.js"
|
import { EmbedChildNode } from "./embed-child.js"
|
||||||
import type { EmbedOptions } from "./embed-options"
|
import type { EmbedOptions } from "./embed-options"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Embed
|
||||||
|
*/
|
||||||
export type EmbedFieldProps = {
|
export type EmbedFieldProps = {
|
||||||
name: string
|
name: string
|
||||||
value?: string
|
value?: string
|
||||||
@@ -10,6 +13,9 @@ export type EmbedFieldProps = {
|
|||||||
children?: string
|
children?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Embed
|
||||||
|
*/
|
||||||
export function EmbedField(props: EmbedFieldProps) {
|
export function EmbedField(props: EmbedFieldProps) {
|
||||||
return (
|
return (
|
||||||
<ReacordElement
|
<ReacordElement
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ import { ReacordElement } from "../../internal/element.js"
|
|||||||
import { EmbedChildNode } from "./embed-child.js"
|
import { EmbedChildNode } from "./embed-child.js"
|
||||||
import type { EmbedOptions } from "./embed-options"
|
import type { EmbedOptions } from "./embed-options"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Embed
|
||||||
|
*/
|
||||||
export type EmbedFooterProps = {
|
export type EmbedFooterProps = {
|
||||||
text?: string
|
text?: string
|
||||||
children?: string
|
children?: string
|
||||||
@@ -10,6 +13,9 @@ export type EmbedFooterProps = {
|
|||||||
timestamp?: string | number | Date
|
timestamp?: string | number | Date
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Embed
|
||||||
|
*/
|
||||||
export function EmbedFooter(props: EmbedFooterProps) {
|
export function EmbedFooter(props: EmbedFooterProps) {
|
||||||
return (
|
return (
|
||||||
<ReacordElement
|
<ReacordElement
|
||||||
|
|||||||
@@ -3,10 +3,16 @@ import { ReacordElement } from "../../internal/element.js"
|
|||||||
import { EmbedChildNode } from "./embed-child.js"
|
import { EmbedChildNode } from "./embed-child.js"
|
||||||
import type { EmbedOptions } from "./embed-options"
|
import type { EmbedOptions } from "./embed-options"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Embed
|
||||||
|
*/
|
||||||
export type EmbedImageProps = {
|
export type EmbedImageProps = {
|
||||||
url: string
|
url: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Embed
|
||||||
|
*/
|
||||||
export function EmbedImage(props: EmbedImageProps) {
|
export function EmbedImage(props: EmbedImageProps) {
|
||||||
return (
|
return (
|
||||||
<ReacordElement
|
<ReacordElement
|
||||||
|
|||||||
@@ -3,10 +3,16 @@ import { ReacordElement } from "../../internal/element.js"
|
|||||||
import { EmbedChildNode } from "./embed-child.js"
|
import { EmbedChildNode } from "./embed-child.js"
|
||||||
import type { EmbedOptions } from "./embed-options"
|
import type { EmbedOptions } from "./embed-options"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Embed
|
||||||
|
*/
|
||||||
export type EmbedThumbnailProps = {
|
export type EmbedThumbnailProps = {
|
||||||
url: string
|
url: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Embed
|
||||||
|
*/
|
||||||
export function EmbedThumbnail(props: EmbedThumbnailProps) {
|
export function EmbedThumbnail(props: EmbedThumbnailProps) {
|
||||||
return (
|
return (
|
||||||
<ReacordElement
|
<ReacordElement
|
||||||
|
|||||||
@@ -3,11 +3,17 @@ import { ReacordElement } from "../../internal/element.js"
|
|||||||
import { EmbedChildNode } from "./embed-child.js"
|
import { EmbedChildNode } from "./embed-child.js"
|
||||||
import type { EmbedOptions } from "./embed-options"
|
import type { EmbedOptions } from "./embed-options"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Embed
|
||||||
|
*/
|
||||||
export type EmbedTitleProps = {
|
export type EmbedTitleProps = {
|
||||||
children: string
|
children: string
|
||||||
url?: string
|
url?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Embed
|
||||||
|
*/
|
||||||
export function EmbedTitle(props: EmbedTitleProps) {
|
export function EmbedTitle(props: EmbedTitleProps) {
|
||||||
return (
|
return (
|
||||||
<ReacordElement
|
<ReacordElement
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ import { TextNode } from "../../internal/text-node"
|
|||||||
import { EmbedChildNode } from "./embed-child.js"
|
import { EmbedChildNode } from "./embed-child.js"
|
||||||
import type { EmbedOptions } from "./embed-options"
|
import type { EmbedOptions } from "./embed-options"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Embed
|
||||||
|
*/
|
||||||
export type EmbedProps = {
|
export type EmbedProps = {
|
||||||
title?: string
|
title?: string
|
||||||
description?: string
|
description?: string
|
||||||
@@ -23,6 +26,9 @@ export type EmbedProps = {
|
|||||||
children?: React.ReactNode
|
children?: React.ReactNode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Embed
|
||||||
|
*/
|
||||||
export function Embed(props: EmbedProps) {
|
export function Embed(props: EmbedProps) {
|
||||||
return (
|
return (
|
||||||
<ReacordElement props={props} createNode={() => new EmbedNode(props)}>
|
<ReacordElement props={props} createNode={() => new EmbedNode(props)}>
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import type { MessageOptions } from "../../internal/message"
|
|||||||
import { getNextActionRow } from "../../internal/message"
|
import { getNextActionRow } from "../../internal/message"
|
||||||
import { Node } from "../../internal/node.js"
|
import { Node } from "../../internal/node.js"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Link
|
||||||
|
*/
|
||||||
export type LinkProps = {
|
export type LinkProps = {
|
||||||
label?: string
|
label?: string
|
||||||
children?: string
|
children?: string
|
||||||
@@ -12,6 +15,9 @@ export type LinkProps = {
|
|||||||
url: string
|
url: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Link
|
||||||
|
*/
|
||||||
export function Link(props: LinkProps) {
|
export function Link(props: LinkProps) {
|
||||||
return <ReacordElement props={props} createNode={() => new LinkNode(props)} />
|
return <ReacordElement props={props} createNode={() => new LinkNode(props)} />
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ import React from "react"
|
|||||||
import { ReacordElement } from "../../internal/element"
|
import { ReacordElement } from "../../internal/element"
|
||||||
import { OptionNode } from "./option-node"
|
import { OptionNode } from "./option-node"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Select
|
||||||
|
*/
|
||||||
export type OptionProps = {
|
export type OptionProps = {
|
||||||
label?: string
|
label?: string
|
||||||
children?: string
|
children?: string
|
||||||
@@ -10,6 +13,9 @@ export type OptionProps = {
|
|||||||
emoji?: string
|
emoji?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Select
|
||||||
|
*/
|
||||||
export function Option(props: OptionProps) {
|
export function Option(props: OptionProps) {
|
||||||
return (
|
return (
|
||||||
<ReacordElement props={props} createNode={() => new OptionNode(props)} />
|
<ReacordElement props={props} createNode={() => new OptionNode(props)} />
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ import { Node } from "../../internal/node.js"
|
|||||||
import type { ComponentEvent } from "../component-event"
|
import type { ComponentEvent } from "../component-event"
|
||||||
import { OptionNode } from "./option-node"
|
import { OptionNode } from "./option-node"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Select
|
||||||
|
*/
|
||||||
export type SelectProps = {
|
export type SelectProps = {
|
||||||
children?: ReactNode
|
children?: ReactNode
|
||||||
value?: string
|
value?: string
|
||||||
@@ -23,10 +26,16 @@ export type SelectProps = {
|
|||||||
onChangeMultiple?: (values: string[], event: SelectChangeEvent) => void
|
onChangeMultiple?: (values: string[], event: SelectChangeEvent) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Select
|
||||||
|
*/
|
||||||
export type SelectChangeEvent = ComponentEvent & {
|
export type SelectChangeEvent = ComponentEvent & {
|
||||||
values: string[]
|
values: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Select
|
||||||
|
*/
|
||||||
export function Select(props: SelectProps) {
|
export function Select(props: SelectProps) {
|
||||||
return (
|
return (
|
||||||
<ReacordElement props={props} createNode={() => new SelectNode(props)}>
|
<ReacordElement props={props} createNode={() => new SelectNode(props)}>
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import type { ReactNode } from "react"
|
import type { ReactNode } from "react"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Core
|
||||||
|
*/
|
||||||
export type ReacordInstance = {
|
export type ReacordInstance = {
|
||||||
render: (content: ReactNode) => void
|
render: (content: ReactNode) => void
|
||||||
deactivate: () => void
|
deactivate: () => void
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ import type { ReacordInstance } from "./instance"
|
|||||||
import type { ReacordConfig } from "./reacord"
|
import type { ReacordConfig } from "./reacord"
|
||||||
import { Reacord } from "./reacord"
|
import { Reacord } from "./reacord"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Reacord adapter for Discord.js.
|
||||||
|
* @category Core
|
||||||
|
*/
|
||||||
export class ReacordDiscordJs extends Reacord {
|
export class ReacordDiscordJs extends Reacord {
|
||||||
constructor(private client: Discord.Client, config: ReacordConfig = {}) {
|
constructor(private client: Discord.Client, config: ReacordConfig = {}) {
|
||||||
super(config)
|
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(
|
override send(
|
||||||
channelId: string,
|
channelId: string,
|
||||||
initialContent?: React.ReactNode,
|
initialContent?: React.ReactNode,
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ import { Reacord } from "./reacord"
|
|||||||
|
|
||||||
const nextTickPromise = promisify(nextTick)
|
const nextTickPromise = promisify(nextTick)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Record adapter for automated tests. WIP
|
||||||
|
*/
|
||||||
export class ReacordTester extends Reacord {
|
export class ReacordTester extends Reacord {
|
||||||
private messageContainer = new Container<TestMessage>()
|
private messageContainer = new Container<TestMessage>()
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import { reconciler } from "../internal/reconciler.js"
|
|||||||
import type { Renderer } from "../internal/renderers/renderer"
|
import type { Renderer } from "../internal/renderers/renderer"
|
||||||
import type { ReacordInstance } from "./instance"
|
import type { ReacordInstance } from "./instance"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Core
|
||||||
|
*/
|
||||||
export type ReacordConfig = {
|
export type ReacordConfig = {
|
||||||
/**
|
/**
|
||||||
* The max number of active instances.
|
* The max number of active instances.
|
||||||
@@ -12,10 +15,10 @@ export type ReacordConfig = {
|
|||||||
maxInstances?: number
|
maxInstances?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ComponentInteractionListener = (
|
/**
|
||||||
interaction: ComponentInteraction,
|
* The main Reacord class that other Reacord adapters should extend.
|
||||||
) => void
|
* Only use this directly if you're making [a custom adapter](/guides/custom-adapters).
|
||||||
|
*/
|
||||||
export abstract class Reacord {
|
export abstract class Reacord {
|
||||||
private renderers: Renderer[] = []
|
private renderers: Renderer[] = []
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user