add options for component event

This commit is contained in:
Domin-MND
2023-10-23 22:02:33 +03:00
parent f998a0e09a
commit 4ee4d4ab91
3 changed files with 15 additions and 10 deletions

View File

@@ -33,15 +33,23 @@ export interface ComponentEvent {
guild?: GuildInfo
/** Create a new reply to this event. */
reply(content?: ReactNode): ReacordInstance
reply(content?: ReactNode, options?: ReplyInfo): ReacordInstance
/**
* Create an ephemeral reply to this event, shown only to the user who
* triggered it.
*
* @deprecated Use event.reply(content, { ephemeral: true })
*/
ephemeralReply(content?: ReactNode): ReacordInstance
}
/** @category Component Event */
export interface ReplyInfo {
ephemeral?: boolean
tts?: boolean
}
/** @category Component Event */
export interface ChannelInfo {
id: string

View File

@@ -18,6 +18,7 @@ import type {
GuildInfo,
GuildMemberInfo,
MessageInfo,
ReplyInfo,
UserInfo,
} from "./component-event"
import type { ReacordInstance } from "./instance"
@@ -59,12 +60,7 @@ export interface CreateMessageReplyOptions {}
*
* @see https://reacord.mapleleaf.dev/guides/sending-messages
*/
export interface CreateInteractionReplyOptions {
/** Whether to send interaction reply as _ephemeral_. */
ephemeral?: boolean
/** Whether to use text-to-speech. */
tts?: boolean
}
export type CreateInteractionReplyOptions = ReplyInfo;
/**
* The Reacord adapter for Discord.js.
@@ -394,12 +390,13 @@ export class ReacordDiscordJs extends Reacord {
user,
guild,
reply: (content?: ReactNode) =>
reply: (content?: ReactNode, options?: ReplyInfo) =>
this.createInstance(
this.createInteractionReplyRenderer(interaction, {}),
this.createInteractionReplyRenderer(interaction, options ?? {}),
content,
),
/** @deprecated Use event.reply(content, { ephemeral: true }) */
ephemeralReply: (content: ReactNode) =>
this.createInstance(
this.createInteractionReplyRenderer(interaction, {

View File

@@ -127,7 +127,7 @@ await createTest("ephemeral button", (channel) => {
/>
<Button
label="clic"
onClick={(event) => event.ephemeralReply("you clic")}
onClick={(event) => event.reply("you clic", { ephemeral: true })}
/>
</>,
)