Files
reacord/library/internal/renderers/command-reply-renderer.ts
2021-12-28 13:53:23 -06:00

23 lines
719 B
TypeScript

import type { CommandInteraction } from "../interaction"
import type { Message, MessageOptions } from "../message"
import { Renderer } from "./renderer"
// keep track of interaction ids which have replies,
// so we know whether to call reply() or followUp()
const repliedInteractionIds = new Set<string>()
export class CommandReplyRenderer extends Renderer {
constructor(private interaction: CommandInteraction) {
super()
}
protected createMessage(options: MessageOptions): Promise<Message> {
if (repliedInteractionIds.has(this.interaction.id)) {
return this.interaction.followUp(options)
}
repliedInteractionIds.add(this.interaction.id)
return this.interaction.reply(options)
}
}