mirror of
https://github.com/chylex/Discord-History-Tracker.git
synced 2025-04-15 16:10:32 +03:00
Add message attachment rendering
This commit is contained in:
parent
45896cc266
commit
6a9d6607ed
@ -37,7 +37,7 @@ var DISCORD = (function(){
|
||||
templateMessage = new TEMPLATE([
|
||||
"<div>",
|
||||
"<h2><strong class='username'>{user.name}</strong><span class='time'>{timestamp}</span></h2>",
|
||||
"<div class='message'>{contents}</div>",
|
||||
"<div class='message'>{contents}{attachments}</div>",
|
||||
"</div>"
|
||||
].join(""));
|
||||
|
||||
@ -86,6 +86,27 @@ var DISCORD = (function(){
|
||||
|
||||
return "<p>"+processed+"</p>";
|
||||
}
|
||||
else if (property === "attachments"){
|
||||
if (!value){
|
||||
return "";
|
||||
}
|
||||
|
||||
return value.map(attachment => {
|
||||
var ext = attachment.url.slice(-4).toLowerCase();
|
||||
|
||||
if (ext === ".png" || ext === ".gif" || ext === ".jpg"){
|
||||
return templateEmbedImage.apply(attachment);
|
||||
}
|
||||
else{
|
||||
var sliced = attachment.url.split("/");
|
||||
|
||||
return templateEmbedDownload.apply({
|
||||
url: attachment.url,
|
||||
filename: sliced[sliced.length-1]
|
||||
});
|
||||
}
|
||||
}).join("");
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -55,7 +55,8 @@ var STATE = (function(){
|
||||
return { // reserve.txt
|
||||
user: FILE.getUser(message.u),
|
||||
timestamp: message.t,
|
||||
contents: message.m
|
||||
contents: message.m,
|
||||
attachments: message.a
|
||||
};
|
||||
});
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user