add options for component event
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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, {
|
||||
|
||||
@@ -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 })}
|
||||
/>
|
||||
</>,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user