mirror of
https://github.com/chylex/Discord-History-Tracker.git
synced 2025-06-04 17:41:08 +03:00
Fix a crash when an embed has a title but no description
This commit is contained in:
parent
33ad6fcba5
commit
6186bcea37
@ -22,6 +22,7 @@ var DISCORD = (function(){
|
||||
var templateMessage;
|
||||
var templateEmbedImage;
|
||||
var templateEmbedRich;
|
||||
var templateEmbedRichNoDescription;
|
||||
var templateEmbedRichUnsupported;
|
||||
var templateEmbedDownload;
|
||||
|
||||
@ -53,7 +54,11 @@ var DISCORD = (function(){
|
||||
].join(""));
|
||||
|
||||
templateEmbedRich = new TEMPLATE([
|
||||
"<div class='embed download'><a href='{url}' class='title'>{t}</a><p>{d}</p></div>"
|
||||
"<div class='embed download'><a href='{url}' class='title'>{t}</a><p class='desc'>{d}</p></div>"
|
||||
].join(""));
|
||||
|
||||
templateEmbedRichNoDescription = new TEMPLATE([
|
||||
"<div class='embed download'><a href='{url}' class='title'>{t}</a></div>"
|
||||
].join(""));
|
||||
|
||||
templateEmbedRichUnsupported = new TEMPLATE([
|
||||
@ -123,7 +128,7 @@ var DISCORD = (function(){
|
||||
return STATE.settings.enableImagePreviews ? templateEmbedImage.apply(embed) : "";
|
||||
|
||||
case "rich":
|
||||
return (embed.t ? templateEmbedRich : templateEmbedRichUnsupported).apply(embed);
|
||||
return (embed.t ? (embed.d ? templateEmbedRich : templateEmbedRichNoDescription) : templateEmbedRichUnsupported).apply(embed);
|
||||
}
|
||||
}).join("");
|
||||
}
|
||||
|
@ -73,7 +73,10 @@
|
||||
.message .embed .title {
|
||||
font-weight: bold;
|
||||
display: inline-block;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.message .embed .desc {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.message .thumbnail {
|
||||
|
@ -179,7 +179,10 @@ SAVEFILE.prototype.convertToMessageObject = function(discordMessage){
|
||||
if (embed.type === "rich"){
|
||||
if (Array.isArray(embed.title) && embed.title.length === 1){
|
||||
conv.t = embed.title[0];
|
||||
conv.d = embed.description[0];
|
||||
|
||||
if (Array.isArray(embed.description) && embed.description.length === 1){
|
||||
conv.d = embed.description[0];
|
||||
}
|
||||
}
|
||||
else{
|
||||
conv.t = "";
|
||||
|
Loading…
x
Reference in New Issue
Block a user