simplify adapter extension

This commit is contained in:
MapleLeaf
2021-12-28 13:10:37 -06:00
parent f36d550963
commit f62b80287d
3 changed files with 38 additions and 51 deletions

View File

@@ -1,11 +1,5 @@
import type { ReactNode } from "react"
import type { Channel } from "../internal/channel"
import { ChannelMessageRenderer } from "../internal/channel-message-renderer"
import { CommandReplyRenderer } from "../internal/command-reply-renderer.js"
import type {
CommandInteraction,
ComponentInteraction,
} from "../internal/interaction"
import type { ComponentInteraction } from "../internal/interaction"
import { reconciler } from "../internal/reconciler.js"
import type { Renderer } from "../internal/renderer"
@@ -49,27 +43,7 @@ export abstract class Reacord {
return this.config.maxInstances ?? 50
}
protected createChannelRendererInstance(
channel: Channel,
initialContent?: ReactNode,
) {
return this.createInstance(
new ChannelMessageRenderer(channel),
initialContent,
)
}
protected createCommandReplyRendererInstance(
commandInteraction: CommandInteraction,
initialContent?: ReactNode,
): ReacordInstance {
return this.createInstance(
new CommandReplyRenderer(commandInteraction),
initialContent,
)
}
private createInstance(renderer: Renderer, initialContent?: ReactNode) {
protected createInstance(renderer: Renderer, initialContent?: ReactNode) {
if (this.renderers.length > this.maxInstances) {
this.deactivate(this.renderers[0]!)
}