mirror of
https://github.com/chylex/Discord-History-Tracker.git
synced 2025-06-09 11:52:09 +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 templateMessage;
|
||||||
var templateEmbedImage;
|
var templateEmbedImage;
|
||||||
var templateEmbedRich;
|
var templateEmbedRich;
|
||||||
|
var templateEmbedRichNoDescription;
|
||||||
var templateEmbedRichUnsupported;
|
var templateEmbedRichUnsupported;
|
||||||
var templateEmbedDownload;
|
var templateEmbedDownload;
|
||||||
|
|
||||||
@ -53,7 +54,11 @@ var DISCORD = (function(){
|
|||||||
].join(""));
|
].join(""));
|
||||||
|
|
||||||
templateEmbedRich = new TEMPLATE([
|
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(""));
|
].join(""));
|
||||||
|
|
||||||
templateEmbedRichUnsupported = new TEMPLATE([
|
templateEmbedRichUnsupported = new TEMPLATE([
|
||||||
@ -123,7 +128,7 @@ var DISCORD = (function(){
|
|||||||
return STATE.settings.enableImagePreviews ? templateEmbedImage.apply(embed) : "";
|
return STATE.settings.enableImagePreviews ? templateEmbedImage.apply(embed) : "";
|
||||||
|
|
||||||
case "rich":
|
case "rich":
|
||||||
return (embed.t ? templateEmbedRich : templateEmbedRichUnsupported).apply(embed);
|
return (embed.t ? (embed.d ? templateEmbedRich : templateEmbedRichNoDescription) : templateEmbedRichUnsupported).apply(embed);
|
||||||
}
|
}
|
||||||
}).join("");
|
}).join("");
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,10 @@
|
|||||||
.message .embed .title {
|
.message .embed .title {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-bottom: 4px;
|
}
|
||||||
|
|
||||||
|
.message .embed .desc {
|
||||||
|
margin-top: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message .thumbnail {
|
.message .thumbnail {
|
||||||
|
@ -179,7 +179,10 @@ SAVEFILE.prototype.convertToMessageObject = function(discordMessage){
|
|||||||
if (embed.type === "rich"){
|
if (embed.type === "rich"){
|
||||||
if (Array.isArray(embed.title) && embed.title.length === 1){
|
if (Array.isArray(embed.title) && embed.title.length === 1){
|
||||||
conv.t = embed.title[0];
|
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{
|
else{
|
||||||
conv.t = "";
|
conv.t = "";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user