embed children

This commit is contained in:
MapleLeaf
2021-12-25 03:54:35 -06:00
parent 6f3c97812c
commit bce472ab37
7 changed files with 130 additions and 44 deletions

View File

@@ -3,34 +3,15 @@ import type {
MessageComponentInteraction,
MessageOptions,
} from "discord.js"
import { Container } from "./container.js"
import type { Node } from "./node.js"
export class Renderer {
private nodes: Array<Node<unknown>> = []
readonly nodes = new Container<Node<unknown>>()
private componentInteraction?: MessageComponentInteraction
constructor(private interaction: CommandInteraction) {}
add(node: Node<unknown>) {
this.nodes.push(node)
}
addBefore(node: Node<unknown>, before: Node<unknown>) {
let index = this.nodes.indexOf(before)
if (index === -1) {
index = this.nodes.length
}
this.nodes.splice(index, 0, node)
}
remove(node: Node<unknown>) {
this.nodes = this.nodes.filter((n) => n !== node)
}
clear() {
this.nodes = []
}
render() {
const options = this.getMessageOptions()
if (this.componentInteraction) {