From 9aa30c6a2e7fac0e59d89de84b414df498284cc8 Mon Sep 17 00:00:00 2001 From: bmonish Date: Sun, 4 Feb 2024 19:46:32 +0530 Subject: [PATCH] feat: Added Millis to Timestamp Command --- src/commands/time.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/commands/time.ts b/src/commands/time.ts index a9fa84f..c05b63d 100644 --- a/src/commands/time.ts +++ b/src/commands/time.ts @@ -2,6 +2,7 @@ import { CacheType, Interaction } from "discord.js"; import moment from "moment-timezone"; const CURRENT_TIME_IN_MILLIS = "CURRENT_TIME_IN_MILLIS"; +const MILLIS_TO_TIMESTAMP = "MILLIS_TO_TIMESTAMP"; export const timeCommand = { name: "time", @@ -14,8 +15,15 @@ export const timeCommand = { type: 3, choices: [ { name: "Current time in millis", value: CURRENT_TIME_IN_MILLIS }, + { name: "Millis to Timestamp", value: MILLIS_TO_TIMESTAMP }, ], }, + { + name: "value", + description: "The value to convert", + required: false, + type: 4, + }, ], execute: async (interaction: Interaction) => { @@ -32,6 +40,19 @@ export const timeCommand = { await interaction.reply(moment().valueOf().toString()); break; } + case MILLIS_TO_TIMESTAMP: { + const valueOption = options.get("value"); + if (!valueOption) { + await interaction.reply("⚠️ Value is required for this operation"); + return; + } + + const value = valueOption.value as number; + await interaction.reply( + moment(value).format("YYYY-MM-DD hh:mm:ss a") + ); + break; + } } } },