mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-03 09:20:08 +00:00
feat(handlers/webhook): support ephemeral messages (#602)
Co-authored-by: ayntee <ayyantee@gmail.com>
This commit is contained in:
@@ -6,10 +6,10 @@ import {
|
||||
EditSlashResponseOptions,
|
||||
EditWebhookMessageOptions,
|
||||
Errors,
|
||||
ExecuteSlashCommandOptions,
|
||||
ExecuteWebhookOptions,
|
||||
MessageCreateOptions,
|
||||
SlashCommand,
|
||||
SlashCommandResponseOptions,
|
||||
UpsertSlashCommandOptions,
|
||||
UpsertSlashCommandsOptions,
|
||||
WebhookCreateOptions,
|
||||
@@ -448,7 +448,7 @@ export function deleteSlashCommand(id: string, guildID?: string) {
|
||||
export async function executeSlashCommand(
|
||||
id: string,
|
||||
token: string,
|
||||
options: ExecuteSlashCommandOptions,
|
||||
options: SlashCommandResponseOptions,
|
||||
) {
|
||||
// If its already been executed, we need to send a followup response
|
||||
if (cache.executedSlashCommands.has(token)) {
|
||||
@@ -464,6 +464,11 @@ export async function executeSlashCommand(
|
||||
900000,
|
||||
);
|
||||
|
||||
// If the user wants this as a private message mark it ephemeral
|
||||
if (options.private) {
|
||||
options.data.flags = 64;
|
||||
}
|
||||
|
||||
// If no mentions are provided, force disable mentions
|
||||
if (!(options.data.allowed_mentions)) {
|
||||
options.data.allowed_mentions = { parse: [] };
|
||||
|
||||
@@ -191,7 +191,7 @@ export interface SlashCommandCallbackData {
|
||||
embeds?: Embed[];
|
||||
/** allowed mentions for the message */
|
||||
"allowed_mentions"?: AllowedMentions;
|
||||
/** acceptable values are message flags */
|
||||
/** acceptable values are message flags, set to 64 to make your response ephemeral */
|
||||
flags?: number;
|
||||
}
|
||||
|
||||
@@ -224,6 +224,12 @@ export interface ExecuteSlashCommandOptions {
|
||||
data: SlashCommandCallbackData;
|
||||
}
|
||||
|
||||
export interface SlashCommandResponseOptions
|
||||
extends ExecuteSlashCommandOptions {
|
||||
/** Whether to make this response visible ONLY to the user who used this command. It will also be deleted after some time. */
|
||||
private?: boolean;
|
||||
}
|
||||
|
||||
export interface EditSlashResponseOptions extends SlashCommandCallbackData {
|
||||
/** If this is not provided, it will default to editing the original response. */
|
||||
messageID?: string;
|
||||
|
||||
Reference in New Issue
Block a user