fix: use embed reverse transformer

This commit is contained in:
Skillz4Killz
2022-03-25 12:32:59 +00:00
committed by GitHub
parent 176d3c0ba7
commit 3bec0cea4d
3 changed files with 3 additions and 147 deletions

View File

@@ -25,55 +25,7 @@ export async function sendInteractionResponse(
const data = {
content: options.data.content,
tts: options.data.tts,
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,
})),
embeds: options.data.embeds?.map((embed) => bot.transformers.reverse.embed(bot, embed)),
allowed_mentions: {
parse: options.data.allowedMentions!.parse,
replied_user: options.data.allowedMentions!.repliedUser,

View File

@@ -13,55 +13,7 @@ export async function editMessage(bot: Bot, channelId: bigint, messageId: bigint
bot.constants.endpoints.CHANNEL_MESSAGE(channelId, messageId),
{
content: content.content,
embeds: content.embeds?.map((embed) => ({
title: embed.title,
type: embed.type,
description: embed.description,
url: embed.url,
timestamp: embed.timestamp ? new Date(embed.timestamp).toISOString() : undefined,
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,
})),
embeds: content.embeds?.map((embed) => bot.transformers.reverse.embed(bot, embed)),
allowed_mentions: {
parse: content.allowedMentions?.parse,
roles: content.allowedMentions?.roles?.map((id) => id.toString()),

View File

@@ -13,55 +13,7 @@ export async function sendMessage(bot: Bot, channelId: bigint, content: CreateMe
{
content: content.content,
tts: content.tts,
embeds: content.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,
})),
embeds: content.embeds?.map((embed) => bot.transformers.reverse.embed(bot, embed)),
allowed_mentions: content.allowedMentions
? {
parse: content.allowedMentions?.parse,