mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-07 13:43:06 -04:00
fix embed translation for ARTICLE type embeds
This commit is contained in:
parent
c341c8bbd3
commit
7defa7e644
2 changed files with 23 additions and 8 deletions
|
@ -11,6 +11,7 @@ const { ApplicationCommandTypes, InteractionCallbackTypes, InteractionContextTyp
|
|||
} = require("detritus-client/lib/constants");
|
||||
const { Components } = require('detritus-client/lib/utils');
|
||||
|
||||
// TODO(unity): utils/translate.js
|
||||
async function translateMessage(context, message, to, from){
|
||||
let mappings = {};
|
||||
|
||||
|
@ -27,7 +28,8 @@ async function translateMessage(context, message, to, from){
|
|||
// Message Translation supports Descriptions and Fields
|
||||
for(const e of message.embeds){
|
||||
let emb = e[1]
|
||||
if(e[1].type !== MessageEmbedTypes.RICH) continue;
|
||||
|
||||
if(![MessageEmbedTypes.ARTICLE,MessageEmbedTypes.RICH].includes(emb.type)) continue;
|
||||
if(emb.description) mappings["embeds/" + i + "/description"] = emb.description;
|
||||
if(emb.title) mappings["embeds/" + i + "/title"] = emb.title;
|
||||
if(emb.author?.name) mappings["embeds/" + i + "/author/name"] = emb.author.name;
|
||||
|
@ -66,17 +68,23 @@ async function translateMessage(context, message, to, from){
|
|||
// Message Translation supports Descriptions and Fields
|
||||
for(const e of message.embeds){
|
||||
let emb = e[1]
|
||||
if(e[1].type !== MessageEmbedTypes.RICH) continue;
|
||||
|
||||
if(![MessageEmbedTypes.ARTICLE,MessageEmbedTypes.RICH].includes(emb.type)) continue;
|
||||
let newEmbed = {
|
||||
fields: []
|
||||
};
|
||||
|
||||
// Elements we don't translate
|
||||
if(emb.color) newEmbed.color = emb.color;
|
||||
if(emb.thumbnail) newEmbed.thumbnail = emb.thumbnail;
|
||||
if(emb.image) newEmbed.image = emb.image;
|
||||
if(emb.url) newEmbed.url = emb.url;
|
||||
|
||||
if(emb.thumbnail){
|
||||
// Special Case, articles render differently
|
||||
if(emb.type === MessageEmbedTypes.ARTICLE) newEmbed.image = emb.thumbnail;
|
||||
else newEmbed.thumbnail = emb.thumbnail;
|
||||
}
|
||||
if(emb.image) newEmbed.image = emb.image;
|
||||
|
||||
if(emb.title) newEmbed.title = stringwrap(tr["embeds/" + i + "/title"], 256);
|
||||
|
||||
if(emb.description) newEmbed.description = stringwrap(tr["embeds/" + i + "/description"], 4096);
|
||||
|
|
|
@ -27,8 +27,8 @@ async function translateMessage(context, message, to, from){
|
|||
// Message Translation supports Descriptions and Fields
|
||||
for(const e of message.embeds){
|
||||
let emb = e[1];
|
||||
if(e[1].type !== MessageEmbedTypes.RICH) continue;
|
||||
|
||||
if(![MessageEmbedTypes.ARTICLE,MessageEmbedTypes.RICH].includes(emb.type)) continue;
|
||||
if(emb.description) mappings["embeds/" + i + "/description"] = emb.description;
|
||||
if(emb.title) mappings["embeds/" + i + "/title"] = emb.title;
|
||||
if(emb.author?.name) mappings["embeds/" + i + "/author/name"] = emb.author.name;
|
||||
|
@ -68,17 +68,24 @@ async function translateMessage(context, message, to, from){
|
|||
for(const e of message.embeds){
|
||||
let emb = e[1]
|
||||
|
||||
if(e[1].type !== MessageEmbedTypes.RICH) continue;
|
||||
if(![MessageEmbedTypes.ARTICLE,MessageEmbedTypes.RICH].includes(emb.type)) continue;
|
||||
let newEmbed = {
|
||||
fields: []
|
||||
};
|
||||
|
||||
// Elements we don't translate
|
||||
if(emb.color) newEmbed.color = emb.color;
|
||||
if(emb.thumbnail) newEmbed.thumbnail = emb.thumbnail;
|
||||
if(emb.image) newEmbed.image = emb.image;
|
||||
if(emb.url) newEmbed.url = emb.url;
|
||||
|
||||
if(emb.thumbnail){
|
||||
// Special Case, articles render differently
|
||||
if(emb.type === MessageEmbedTypes.ARTICLE) newEmbed.image = emb.thumbnail;
|
||||
else newEmbed.thumbnail = emb.thumbnail;
|
||||
}
|
||||
|
||||
if(emb.image) newEmbed.image = emb.image;
|
||||
|
||||
|
||||
if(emb.title) newEmbed.title = stringwrap(tr["embeds/" + i + "/title"], 256);
|
||||
|
||||
if(emb.description) newEmbed.description = stringwrap(tr["embeds/" + i + "/description"], 4096);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue