mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-11-15 02:21:21 +01:00
Clean up mention with mustache
This commit is contained in:
parent
6a2a3d1f34
commit
07bd0b5f5b
@ -682,16 +682,17 @@
|
|||||||
|
|
||||||
function replace_message_mentions(message) {
|
function replace_message_mentions(message) {
|
||||||
var mentions = message.mentions;
|
var mentions = message.mentions;
|
||||||
|
var template = $('#mustache_discordmention').html();
|
||||||
|
Mustache.parse(template);
|
||||||
for (var i = 0; i < mentions.length; i++) {
|
for (var i = 0; i < mentions.length; i++) {
|
||||||
var mention = mentions[i];
|
var mention = mentions[i];
|
||||||
var username = mention.username;
|
var username = mention.username;
|
||||||
if (mention.nickname) {
|
if (mention.nickname) {
|
||||||
username = mention.nickname;
|
username = mention.nickname;
|
||||||
}
|
}
|
||||||
console.log(message.content)
|
var rendered = Mustache.render(template, {"username": username, "discriminator": mention.discriminator}).trim();
|
||||||
var templ = "<span class=\"mention\">@<span class=\"username\">" + username + "</span><span class=\"discriminator\">#" + mention.discriminator + "</span></span>";
|
message.content = message.content.replace(new RegExp("<@" + mention.id + ">", 'g'), rendered);
|
||||||
message.content = message.content.replace(new RegExp("<@" + mention.id + ">", 'g'), templ);
|
message.content = message.content.replace(new RegExp("<@!" + mention.id + ">", 'g'), rendered);
|
||||||
message.content = message.content.replace(new RegExp("<@!" + mention.id + ">", 'g'), templ);
|
|
||||||
message.content = message.content.replace("<@&" + guild_id + ">", "@everyone");
|
message.content = message.content.replace("<@&" + guild_id + ">", "@everyone");
|
||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
|
@ -233,6 +233,10 @@
|
|||||||
<img class="message_emoji tooltipped" src='https://cdn.discordapp.com/emojis/{{id}}.png' data-position="top" data-delay="200" data-tooltip=":{{name}}:" alt=":{{name}}:" />
|
<img class="message_emoji tooltipped" src='https://cdn.discordapp.com/emojis/{{id}}.png' data-position="top" data-delay="200" data-tooltip=":{{name}}:" alt=":{{name}}:" />
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script id="mustache_discordmention" type="text/template">
|
||||||
|
<span class="discordmention"><span class="atsign">@</span><span class="username">{{username}}</span><span class="hash">#</span><span class="discriminator">{{discriminator}}</span></span>
|
||||||
|
</script>
|
||||||
|
|
||||||
<script id="mustache_richembed" type="text/template">
|
<script id="mustache_richembed" type="text/template">
|
||||||
<div class="richembed">
|
<div class="richembed">
|
||||||
{{#color}}
|
{{#color}}
|
||||||
|
Loading…
Reference in New Issue
Block a user