move things to folders

This commit is contained in:
itsMapleLeaf
2022-07-25 11:03:55 -05:00
parent 9a96da1d34
commit 67b1f45a8f
13 changed files with 34 additions and 46 deletions

View File

@@ -1,5 +1,5 @@
import type { ButtonNode } from "./button" import type { ButtonNode } from "./button"
import { Container } from "./container" import { Container } from "../../helpers/container"
export type NodeBase<Type extends string, Props> = { export type NodeBase<Type extends string, Props> = {
type: Type type: Type

View File

@@ -1,5 +1,5 @@
import type { ReactNode } from "react" import type { ReactNode } from "react"
import { Container } from "./container" import { Container } from "../../helpers/container"
import type { MessagePayload } from "./make-message-payload" import type { MessagePayload } from "./make-message-payload"
import { makeMessagePayload } from "./make-message-payload" import { makeMessagePayload } from "./make-message-payload"
import type { Node } from "./node" import type { Node } from "./node"

View File

@@ -1,6 +1,6 @@
import ReactReconciler from "react-reconciler" import ReactReconciler from "react-reconciler"
import { DefaultEventPriority } from "react-reconciler/constants" import { DefaultEventPriority } from "react-reconciler/constants"
import type { Container } from "./container" import type { Container } from "../../helpers/container"
import type { Node, TextNode } from "./node" import type { Node, TextNode } from "./node"
import { makeNode, NodeRef } from "./node" import { makeNode, NodeRef } from "./node"

View File

@@ -1,33 +1,9 @@
import type { Client, Interaction, Message, TextBasedChannel } from "discord.js" import type { Client, Message, TextBasedChannel } from "discord.js"
import { ButtonStyle } from "discord.js" import { AsyncQueue } from "../../helpers/async-queue"
import type { ReactNode } from "react" import type { MessagePayload as MessagePayloadType } from "../core/make-message-payload"
import { AsyncQueue } from "./async-queue" import type { ReacordMessageRenderer } from "../core/reacord-instance-pool"
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"
export class ReacordDiscordJs { export class ChannelMessageRenderer implements ReacordMessageRenderer {
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 {
private message: Message | undefined private message: Message | undefined
private channel: TextBasedChannel | undefined private channel: TextBasedChannel | undefined
private active = true private active = true
@@ -86,13 +62,3 @@ class ChannelMessageRenderer implements ReacordMessageRenderer {
return (this.channel = channel) 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]
}

View 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) {}
}

View File

@@ -1,7 +1,7 @@
export { Button, type ButtonProps } from "./button" export { Button, type ButtonProps } from "./core/button"
export { type ButtonSharedProps } from "./button-shared-props" export { type ButtonSharedProps } from "./core/button-shared-props"
export { ReacordDiscordJs } from "./reacord-discord-js"
export { export {
type ReacordInstance, type ReacordInstance,
type ReacordOptions, type ReacordOptions,
} from "./reacord-instance-pool" } from "./core/reacord-instance-pool"
export { ReacordDiscordJs } from "./djs/reacord-discord-js"