Fix a crash when an embed has a title but no description

This commit is contained in:
chylex 2018-02-08 21:23:27 +01:00
parent 33ad6fcba5
commit 6186bcea37
3 changed files with 15 additions and 4 deletions

View File

@ -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("");
}

View File

@ -73,7 +73,10 @@
.message .embed .title {
font-weight: bold;
display: inline-block;
margin-bottom: 4px;
}
.message .embed .desc {
margin-top: 4px;
}
.message .thumbnail {

View File

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