beginnings of new api

This commit is contained in:
MapleLeaf
2021-12-25 00:52:21 -06:00
parent fa95b42be6
commit e799e71f1a
9 changed files with 177 additions and 45 deletions

34
src.new/root-node.ts Normal file
View File

@@ -0,0 +1,34 @@
import type { CommandInteraction, MessageOptions } from "discord.js"
import type { TextNode } from "./text-node.js"
export class RootNode {
private children = new Set<TextNode>()
constructor(private interaction: CommandInteraction) {}
add(child: TextNode) {
this.children.add(child)
}
clear() {
this.children.clear()
}
remove(child: TextNode) {
this.children.delete(child)
}
render() {
this.interaction.reply(this.getMessageOptions()).catch(console.error)
}
getMessageOptions() {
const options: MessageOptions = {}
for (const child of this.children) {
options.content = (options.content ?? "") + child.text
}
return options
}
}