add options for component event
This commit is contained in:
@@ -33,15 +33,23 @@ export interface ComponentEvent {
|
|||||||
guild?: GuildInfo
|
guild?: GuildInfo
|
||||||
|
|
||||||
/** Create a new reply to this event. */
|
/** 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
|
* Create an ephemeral reply to this event, shown only to the user who
|
||||||
* triggered it.
|
* triggered it.
|
||||||
|
*
|
||||||
|
* @deprecated Use event.reply(content, { ephemeral: true })
|
||||||
*/
|
*/
|
||||||
ephemeralReply(content?: ReactNode): ReacordInstance
|
ephemeralReply(content?: ReactNode): ReacordInstance
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @category Component Event */
|
||||||
|
export interface ReplyInfo {
|
||||||
|
ephemeral?: boolean
|
||||||
|
tts?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
/** @category Component Event */
|
/** @category Component Event */
|
||||||
export interface ChannelInfo {
|
export interface ChannelInfo {
|
||||||
id: string
|
id: string
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import type {
|
|||||||
GuildInfo,
|
GuildInfo,
|
||||||
GuildMemberInfo,
|
GuildMemberInfo,
|
||||||
MessageInfo,
|
MessageInfo,
|
||||||
|
ReplyInfo,
|
||||||
UserInfo,
|
UserInfo,
|
||||||
} from "./component-event"
|
} from "./component-event"
|
||||||
import type { ReacordInstance } from "./instance"
|
import type { ReacordInstance } from "./instance"
|
||||||
@@ -59,12 +60,7 @@ export interface CreateMessageReplyOptions {}
|
|||||||
*
|
*
|
||||||
* @see https://reacord.mapleleaf.dev/guides/sending-messages
|
* @see https://reacord.mapleleaf.dev/guides/sending-messages
|
||||||
*/
|
*/
|
||||||
export interface CreateInteractionReplyOptions {
|
export type CreateInteractionReplyOptions = ReplyInfo;
|
||||||
/** Whether to send interaction reply as _ephemeral_. */
|
|
||||||
ephemeral?: boolean
|
|
||||||
/** Whether to use text-to-speech. */
|
|
||||||
tts?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Reacord adapter for Discord.js.
|
* The Reacord adapter for Discord.js.
|
||||||
@@ -394,12 +390,13 @@ export class ReacordDiscordJs extends Reacord {
|
|||||||
user,
|
user,
|
||||||
guild,
|
guild,
|
||||||
|
|
||||||
reply: (content?: ReactNode) =>
|
reply: (content?: ReactNode, options?: ReplyInfo) =>
|
||||||
this.createInstance(
|
this.createInstance(
|
||||||
this.createInteractionReplyRenderer(interaction, {}),
|
this.createInteractionReplyRenderer(interaction, options ?? {}),
|
||||||
content,
|
content,
|
||||||
),
|
),
|
||||||
|
|
||||||
|
/** @deprecated Use event.reply(content, { ephemeral: true }) */
|
||||||
ephemeralReply: (content: ReactNode) =>
|
ephemeralReply: (content: ReactNode) =>
|
||||||
this.createInstance(
|
this.createInstance(
|
||||||
this.createInteractionReplyRenderer(interaction, {
|
this.createInteractionReplyRenderer(interaction, {
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ await createTest("ephemeral button", (channel) => {
|
|||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
label="clic"
|
label="clic"
|
||||||
onClick={(event) => event.ephemeralReply("you clic")}
|
onClick={(event) => event.reply("you clic", { ephemeral: true })}
|
||||||
/>
|
/>
|
||||||
</>,
|
</>,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user