New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

timecord

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

timecord

Tool to easily create and manipulate discord timestamps.

latest
Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

TimeCord — Timestamps for Discord

TimeCord is a Node.js module that allows you to easily create timestamps!

Installation

npm install timecord
yarn add timecord

Basic usage

const { DiscordTimestamp } = require('timecord');

const timestamp = new DiscordTimestamp();
console.log(timestamp.format()); // -> <t:xxxxxxx:f>

Example

const { Client } = require('discord.js');
const client = new Client(...);

const { DiscordTimestamp } = require('timecord');

client.on('interactionCreate', (interaction) => {
	if (interaction.isChatInputCommand() && interaction.commandName === 'test-timestamp') {
		const createdDate = new DiscordTimestamp(interaction.createdAt).format();
		return interaction.reply({
			content: `Interaction created date: ${createdDate}`
		});
		// -> content: `Interaction created date: <t:xxxxxxxx:f>`
	}
});

Advanced example

const { DiscordTimestamp, StyleType, TimeUnits } = require('timecord');

const timestamp = new DiscordTimestamp(new Date(), StyleType.RelativeTime);

console.log(`You will be able to use this command again ${timestamp.addTime(2, TimeUnits.Hours).format()}.`);
// -> You will be able to use this command again in 2 hours.

Methods

MethodParametersDescription
addTimeamount: number
time?: TimeUnitResolvable
Adds time to the timestamp.
subtractTimeamount: number
time?: TimeUnitResolvable
Subtracts time to the timestamp.
resetTimestampnoneResets the timestamp.
setTimestamptimestamp: TimestampResolvable
style?: StyleResolvable
Sets the timestamp.
setStylestyle: StyleResolvableSets the style.
formatstyle?: StyleResolvableFormats the timestamp to a TimestampResult.

Types

NameType
TimestampResolvableDate | number | string
TimestampStyle"t" | "T" | "d" | "D" | "f" | "F" | "R"
TimestampResult`<t:${number}:${StyleType[number]}>`
StyleResolvableStyleType | keyof typeof StyleType
TimeUnitResolvableTimeUnits | keyof typeof TimeUnits

Enums

NamePropertyValueExample Output
TimeUnitsMiliseconds
Seconds
Minutes
Hours
Days
1
1000
60000
3.6e6
8.64e7
This will be multiplied by the number passed by parameters in a function.
<Number> * <Value>
StyleTypeShortTime
LongTime
ShortDate
LongDate
ShortDateAndTime
LongDateAndTime
RelativeTime
't'
'T'
'd'
'D'
'f'
'F'
'R'
16:20
16:20:30
20/04/2021
20 April 2021
20 April 2021 16:20
Tuesday, 20 April 2021 16:20
2 months ago

Keywords

discord

FAQs

Package last updated on 20 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts