feat(handlers/webhook): support ephemeral messages (#602)

Co-authored-by: ayntee <ayyantee@gmail.com>
This commit is contained in:
Skillz4Killz
2021-03-06 13:59:45 -05:00
committed by GitHub
parent 33ff8cd752
commit e5bf5cd47c
2 changed files with 14 additions and 3 deletions

View File

@@ -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: [] };

View File

@@ -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;