Skip to content

Commit

Permalink
feat: Added Millis to Timestamp Command
Browse files Browse the repository at this point in the history
  • Loading branch information
bmonish committed Apr 12, 2024
1 parent 57a64e9 commit 9aa30c6
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/commands/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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<CacheType>) => {
Expand All @@ -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;
}
}
}
},
Expand Down

0 comments on commit 9aa30c6

Please sign in to comment.