Skip to content

Commit

Permalink
change duration format to Discord timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanThatOneKid committed Oct 1, 2023
1 parent 85ab40b commit 9597d8e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,11 @@ export function makeHandler(kv: Deno.Kv) {
let content =
`Created commit [${result.message}](https://acmcsuf.com/code/commit/${result.sha})!`;
if (ttlDuration) {
// Render to Discord timestamp format.
// https://gist.github.com/LeviSnoot/d9147767abeef2f770e9ddcd91eb85aa
const discordTimestamp = `<t:${Date.now() + ttlDuration.raw}:R>`;
content +=
`\n\nThis shortlink will be expire in ${ttlDuration.toShortString()}.`;
`\n\nThis shortlink will be expire in ${discordTimestamp}.`;
}

// Send the success message.
Expand Down

0 comments on commit 9597d8e

Please sign in to comment.