move things to folders
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import type { ButtonNode } from "./button"
|
||||
import { Container } from "./container"
|
||||
import { Container } from "../../helpers/container"
|
||||
|
||||
export type NodeBase<Type extends string, Props> = {
|
||||
type: Type
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { ReactNode } from "react"
|
||||
import { Container } from "./container"
|
||||
import { Container } from "../../helpers/container"
|
||||
import type { MessagePayload } from "./make-message-payload"
|
||||
import { makeMessagePayload } from "./make-message-payload"
|
||||
import type { Node } from "./node"
|
||||
@@ -1,6 +1,6 @@
|
||||
import ReactReconciler from "react-reconciler"
|
||||
import { DefaultEventPriority } from "react-reconciler/constants"
|
||||
import type { Container } from "./container"
|
||||
import type { Container } from "../../helpers/container"
|
||||
import type { Node, TextNode } from "./node"
|
||||
import { makeNode, NodeRef } from "./node"
|
||||
|
||||
@@ -1,33 +1,9 @@
|
||||
import type { Client, Interaction, Message, TextBasedChannel } from "discord.js"
|
||||
import { ButtonStyle } from "discord.js"
|
||||
import type { ReactNode } from "react"
|
||||
import { AsyncQueue } from "./async-queue"
|
||||
import type { ButtonProps } from "./button"
|
||||
import type { MessagePayload as MessagePayloadType } from "./make-message-payload"
|
||||
import type {
|
||||
ReacordMessageRenderer,
|
||||
ReacordOptions,
|
||||
} from "./reacord-instance-pool"
|
||||
import { ReacordInstancePool } from "./reacord-instance-pool"
|
||||
import type { Client, Message, TextBasedChannel } from "discord.js"
|
||||
import { AsyncQueue } from "../../helpers/async-queue"
|
||||
import type { MessagePayload as MessagePayloadType } from "../core/make-message-payload"
|
||||
import type { ReacordMessageRenderer } from "../core/reacord-instance-pool"
|
||||
|
||||
export class ReacordDiscordJs {
|
||||
private instances
|
||||
|
||||
constructor(private readonly client: Client, options: ReacordOptions = {}) {
|
||||
this.instances = new ReacordInstancePool(options)
|
||||
}
|
||||
|
||||
send(channelId: string, initialContent?: ReactNode) {
|
||||
const renderer = new ChannelMessageRenderer(this.client, channelId)
|
||||
return this.instances.create({ initialContent, renderer })
|
||||
}
|
||||
|
||||
reply(interaction: Interaction, initialContent?: ReactNode) {}
|
||||
|
||||
ephemeralReply(interaction: Interaction, initialContent?: ReactNode) {}
|
||||
}
|
||||
|
||||
class ChannelMessageRenderer implements ReacordMessageRenderer {
|
||||
export class ChannelMessageRenderer implements ReacordMessageRenderer {
|
||||
private message: Message | undefined
|
||||
private channel: TextBasedChannel | undefined
|
||||
private active = true
|
||||
@@ -86,13 +62,3 @@ class ChannelMessageRenderer implements ReacordMessageRenderer {
|
||||
return (this.channel = channel)
|
||||
}
|
||||
}
|
||||
|
||||
function getButtonStyle(style: NonNullable<ButtonProps["style"]>) {
|
||||
const styleMap = {
|
||||
primary: ButtonStyle.Primary,
|
||||
secondary: ButtonStyle.Secondary,
|
||||
danger: ButtonStyle.Danger,
|
||||
success: ButtonStyle.Success,
|
||||
} as const
|
||||
return styleMap[style]
|
||||
}
|
||||
22
packages/reacord/library.new/djs/reacord-discord-js.ts
Normal file
22
packages/reacord/library.new/djs/reacord-discord-js.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import type { Client, Interaction } from "discord.js"
|
||||
import type { ReactNode } from "react"
|
||||
import type { ReacordOptions } from "../core/reacord-instance-pool"
|
||||
import { ReacordInstancePool } from "../core/reacord-instance-pool"
|
||||
import { ChannelMessageRenderer } from "./channel-message-renderer"
|
||||
|
||||
export class ReacordDiscordJs {
|
||||
private instances
|
||||
|
||||
constructor(private readonly client: Client, options: ReacordOptions = {}) {
|
||||
this.instances = new ReacordInstancePool(options)
|
||||
}
|
||||
|
||||
send(channelId: string, initialContent?: ReactNode) {
|
||||
const renderer = new ChannelMessageRenderer(this.client, channelId)
|
||||
return this.instances.create({ initialContent, renderer })
|
||||
}
|
||||
|
||||
reply(interaction: Interaction, initialContent?: ReactNode) {}
|
||||
|
||||
ephemeralReply(interaction: Interaction, initialContent?: ReactNode) {}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
export { Button, type ButtonProps } from "./button"
|
||||
export { type ButtonSharedProps } from "./button-shared-props"
|
||||
export { ReacordDiscordJs } from "./reacord-discord-js"
|
||||
export { Button, type ButtonProps } from "./core/button"
|
||||
export { type ButtonSharedProps } from "./core/button-shared-props"
|
||||
export {
|
||||
type ReacordInstance,
|
||||
type ReacordOptions,
|
||||
} from "./reacord-instance-pool"
|
||||
} from "./core/reacord-instance-pool"
|
||||
export { ReacordDiscordJs } from "./djs/reacord-discord-js"
|
||||
|
||||
Reference in New Issue
Block a user