mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-11-15 02:21:21 +01:00
Parsing message timestamps, so they look cleaner
This commit is contained in:
parent
13e9649c10
commit
0bf87ae4b4
@ -3,6 +3,7 @@
|
|||||||
/* global Mustache */
|
/* global Mustache */
|
||||||
/* global guild_id */
|
/* global guild_id */
|
||||||
/* global bot_client_id */
|
/* global bot_client_id */
|
||||||
|
/* global moment */
|
||||||
|
|
||||||
var logintimer; // timer to keep track of user inactivity after hitting login
|
var logintimer; // timer to keep track of user inactivity after hitting login
|
||||||
var fetchtimeout; // fetch routine timer
|
var fetchtimeout; // fetch routine timer
|
||||||
@ -235,7 +236,14 @@ function format_bot_message(message) {
|
|||||||
message.author.username = usernamefield.split("#")[0];
|
message.author.username = usernamefield.split("#")[0];
|
||||||
message.author.discriminator = usernamefield.split("#")[1];
|
message.author.discriminator = usernamefield.split("#")[1];
|
||||||
}
|
}
|
||||||
return message
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
function parse_message_time(message) {
|
||||||
|
var mome = moment(message.timestamp);
|
||||||
|
message.formatted_timestamp = mome.toDate().toString();
|
||||||
|
message.formatted_time = mome.format("HH:mm A");
|
||||||
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fill_discord_messages(messages, jumpscroll) {
|
function fill_discord_messages(messages, jumpscroll) {
|
||||||
@ -249,7 +257,8 @@ function fill_discord_messages(messages, jumpscroll) {
|
|||||||
var message = messages[i];
|
var message = messages[i];
|
||||||
message = replace_message_mentions(message);
|
message = replace_message_mentions(message);
|
||||||
message = format_bot_message(message);
|
message = format_bot_message(message);
|
||||||
var rendered = Mustache.render(template, {"id": message.id, "full_timestamp": message.timestamp, "time": message.timestamp, "username": message.author.username, "discriminator": message.author.discriminator, "content": message.content});
|
message = parse_message_time(message);
|
||||||
|
var rendered = Mustache.render(template, {"id": message.id, "full_timestamp": message.formatted_timestamp, "time": message.formatted_time, "username": message.author.username, "discriminator": message.author.discriminator, "content": message.content});
|
||||||
$("#chatcontent").append(rendered);
|
$("#chatcontent").append(rendered);
|
||||||
last = message.id;
|
last = message.id;
|
||||||
}
|
}
|
||||||
|
@ -96,6 +96,7 @@
|
|||||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
|
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
|
||||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.1/js/materialize.min.js" integrity="sha256-ToPQhpo/E89yaCd7+V8LUCjobNRkjilRXfho6x3twLU=" crossorigin="anonymous"></script>
|
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.1/js/materialize.min.js" integrity="sha256-ToPQhpo/E89yaCd7+V8LUCjobNRkjilRXfho6x3twLU=" crossorigin="anonymous"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mustache.js/2.3.0/mustache.min.js" integrity="sha256-iaqfO5ue0VbSGcEiQn+OeXxnxAMK2+QgHXIDA5bWtGI=" crossorigin="anonymous"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/mustache.js/2.3.0/mustache.min.js" integrity="sha256-iaqfO5ue0VbSGcEiQn+OeXxnxAMK2+QgHXIDA5bWtGI=" crossorigin="anonymous"></script>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js" integrity="sha256-1hjUhpc44NwiNg8OwMu2QzJXhD8kcj+sJA3aCQZoUjg=" crossorigin="anonymous"></script>
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
<script id="mustache_channellistings" type="text/template">
|
<script id="mustache_channellistings" type="text/template">
|
||||||
|
Loading…
Reference in New Issue
Block a user