From 5ab6f5959363cef464bcca5cfebf46358a94ad48 Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Mon, 2 Dec 2019 01:11:40 +0200 Subject: [PATCH] starboard: localized timestamps; add link to original message again --- backend/src/plugins/Starboard.ts | 7 +++++-- backend/src/utils.ts | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/src/plugins/Starboard.ts b/backend/src/plugins/Starboard.ts index d0056626..e51e637b 100644 --- a/backend/src/plugins/Starboard.ts +++ b/backend/src/plugins/Starboard.ts @@ -11,6 +11,7 @@ import { tNullable, tDeepPartial, UnknownUser, + EMPTY_CHAR, } from "../utils"; import path from "path"; import moment from "moment-timezone"; @@ -247,12 +248,12 @@ export class StarboardPlugin extends ZeppelinPlugin { const embed: EmbedBase = { footer: { - text: `#${(msg.channel as GuildChannel).name} - ${time}`, + text: `#${(msg.channel as GuildChannel).name}`, }, author: { name: `${msg.author.username}#${msg.author.discriminator}`, }, - url: messageLink(msg), + timestamp: new Date(msg.timestamp).toISOString(), }; if (msg.author.avatarURL) { @@ -280,6 +281,8 @@ export class StarboardPlugin extends ZeppelinPlugin { embed.image = msg.embeds[0].image; } + embed.fields = [{ name: EMPTY_CHAR, value: `[Jump to message](${messageLink(msg)})` }]; + const starboardMessage = await (channel as TextChannel).createMessage({ embed }); await this.starboardMessages.createStarboardMessage(channel.id, msg.id, starboardMessage.id); } diff --git a/backend/src/utils.ts b/backend/src/utils.ts index 009fcdcc..9542c48b 100644 --- a/backend/src/utils.ts +++ b/backend/src/utils.ts @@ -49,6 +49,8 @@ export const HOURS = 60 * MINUTES; export const DAYS = 24 * HOURS; export const WEEKS = 7 * 24 * HOURS; +export const EMPTY_CHAR = "\u200b"; + export function tNullable>(type: T) { return t.union([type, t.undefined, t.null], `Nullable<${type.name}>`); }