From 4e709abed8b725b5457a36119737b9c485dc563c Mon Sep 17 00:00:00 2001 From: TriForMine Date: Sat, 30 Oct 2021 15:32:59 +0200 Subject: [PATCH 1/5] Fix sendInteractionResponse again --- src/helpers/interactions/send_interaction_response.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/interactions/send_interaction_response.ts b/src/helpers/interactions/send_interaction_response.ts index 6568b4009..78b2d29be 100644 --- a/src/helpers/interactions/send_interaction_response.ts +++ b/src/helpers/interactions/send_interaction_response.ts @@ -32,7 +32,7 @@ export async function sendInteractionResponse( options.data = { ...options.data, allowedMentions: { parse: [] } }; } - const allowedMentions: AllowedMentions = options.data?.allowedMentions || { parse: [] }; + const allowedMentions: AllowedMentions = options.data?.allowedMentions; // If its already been executed, we need to send a followup response if (bot.cache.executedSlashCommands.has(token)) { From ac6b82810301e655491a2261773fa05137592bf8 Mon Sep 17 00:00:00 2001 From: TriForMine Date: Sat, 30 Oct 2021 15:36:30 +0200 Subject: [PATCH 2/5] Update send_interaction_response.ts --- .../interactions/send_interaction_response.ts | 64 +++++++++++++++++-- 1 file changed, 57 insertions(+), 7 deletions(-) diff --git a/src/helpers/interactions/send_interaction_response.ts b/src/helpers/interactions/send_interaction_response.ts index 78b2d29be..98174c8dc 100644 --- a/src/helpers/interactions/send_interaction_response.ts +++ b/src/helpers/interactions/send_interaction_response.ts @@ -117,13 +117,63 @@ export async function sendInteractionResponse( { content: options.data.content, tts: options.data.tts, - embeds: options.data.embeds, - allowed_mentions: { - parse: allowedMentions.parse, - roles: allowedMentions.roles, - users: allowedMentions.users, - replied_user: allowedMentions.repliedUser, - }, + embeds: options.data.embeds?.map((embed) => ({ + title: embed.title, + type: embed.type, + description: embed.description, + url: embed.url, + timestamp: embed.timestamp, + color: embed.color, + footer: embed.footer + ? { + text: embed.footer.text, + icon_url: embed.footer.iconUrl, + proxy_icon_url: embed.footer.proxyIconUrl, + } + : undefined, + image: embed.image + ? { + url: embed.image.url, + proxy_url: embed.image.proxyUrl, + height: embed.image.height, + width: embed.image.width, + } + : undefined, + thumbnail: embed.thumbnail + ? { + url: embed.thumbnail.url, + proxy_url: embed.thumbnail.proxyUrl, + height: embed.thumbnail.height, + width: embed.thumbnail.width, + } + : undefined, + video: embed.video + ? { + url: embed.video.url, + proxy_url: embed.video.proxyUrl, + height: embed.video.height, + width: embed.video.width, + } + : undefined, + provider: embed.provider, + author: embed.author + ? { + name: embed.author.name, + url: embed.author.url, + icon_url: embed.author.iconUrl, + proxy_icon_url: embed.author.proxyIconUrl, + } + : undefined, + fields: embed.fields, + })), + allowed_mentions: allowedMentions + ? { + parse: allowedMentions?.parse, + roles: allowedMentions?.roles, + users: allowedMentions?.users, + replied_user: allowedMentions?.repliedUser, + } + : undefined, file: options.data.file, // TODO: Snakelize components?? components: options.data.components, From 971443cdf4bbd341823d05843d091937f172488e Mon Sep 17 00:00:00 2001 From: TriForMine Date: Sat, 30 Oct 2021 13:37:05 +0000 Subject: [PATCH 3/5] change: prettier code --- src/helpers/interactions/send_interaction_response.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/interactions/send_interaction_response.ts b/src/helpers/interactions/send_interaction_response.ts index 98174c8dc..d11a80cbe 100644 --- a/src/helpers/interactions/send_interaction_response.ts +++ b/src/helpers/interactions/send_interaction_response.ts @@ -117,7 +117,7 @@ export async function sendInteractionResponse( { content: options.data.content, tts: options.data.tts, - embeds: options.data.embeds?.map((embed) => ({ + embeds: options.data.embeds?.map((embed) => ({ title: embed.title, type: embed.type, description: embed.description, From 12ea44e838ac632e30b5327dc8346f63b415d8f8 Mon Sep 17 00:00:00 2001 From: TriForMine Date: Sat, 30 Oct 2021 15:37:43 +0200 Subject: [PATCH 4/5] Update send_interaction_response.ts --- src/helpers/interactions/send_interaction_response.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/interactions/send_interaction_response.ts b/src/helpers/interactions/send_interaction_response.ts index d11a80cbe..357518b85 100644 --- a/src/helpers/interactions/send_interaction_response.ts +++ b/src/helpers/interactions/send_interaction_response.ts @@ -32,7 +32,7 @@ export async function sendInteractionResponse( options.data = { ...options.data, allowedMentions: { parse: [] } }; } - const allowedMentions: AllowedMentions = options.data?.allowedMentions; + const allowedMentions: AllowedMentions = options.data?.allowedMentions || { parse: [] }; // If its already been executed, we need to send a followup response if (bot.cache.executedSlashCommands.has(token)) { From a539673de1d6dd16286ba57ca5e0c6d8d48ca5b9 Mon Sep 17 00:00:00 2001 From: TriForMine Date: Sat, 30 Oct 2021 15:40:58 +0200 Subject: [PATCH 5/5] Update send_interaction_response.ts --- .../interactions/send_interaction_response.ts | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/helpers/interactions/send_interaction_response.ts b/src/helpers/interactions/send_interaction_response.ts index 357518b85..9a7e8e890 100644 --- a/src/helpers/interactions/send_interaction_response.ts +++ b/src/helpers/interactions/send_interaction_response.ts @@ -88,14 +88,12 @@ export async function sendInteractionResponse( : undefined, fields: embed.fields, })), - allowed_mentions: allowedMentions - ? { - parse: allowedMentions?.parse, - roles: allowedMentions?.roles, - users: allowedMentions?.users, - replied_user: allowedMentions?.repliedUser, - } - : undefined, + allowed_mentions: { + parse: allowedMentions?.parse, + roles: allowedMentions?.roles, + users: allowedMentions?.users, + replied_user: allowedMentions?.repliedUser, + }, file: options.data.file, // TODO: Snakelize components?? components: options.data.components, @@ -166,14 +164,12 @@ export async function sendInteractionResponse( : undefined, fields: embed.fields, })), - allowed_mentions: allowedMentions - ? { - parse: allowedMentions?.parse, - roles: allowedMentions?.roles, - users: allowedMentions?.users, - replied_user: allowedMentions?.repliedUser, - } - : undefined, + allowed_mentions: { + parse: allowedMentions?.parse, + roles: allowedMentions?.roles, + users: allowedMentions?.users, + replied_user: allowedMentions?.repliedUser, + }, file: options.data.file, // TODO: Snakelize components?? components: options.data.components,