MCPcopy Index your code
hub / github.com/codebymitch/TitanBot / execute

Function execute

src/commands/Tools/unixtime.js:11–37  ·  view source on GitHub ↗
(interaction)

Source from the content-addressed store, hash-verified

9 .setDescription('Get the current Unix timestamp'),
10
11 async execute(interaction) {
12 await InteractionHelper.safeExecute(
13 interaction,
14 async () => {
15 const now = new Date();
16 const unixTimestamp = Math.floor(now.getTime() / 1000);
17
18 const embed = successEmbed(
19 '⏱️ Current Unix Timestamp',
20 `**Seconds since Unix Epoch:** \`${unixTimestamp}\`\n` +
21 `**Milliseconds since Unix Epoch:** \`${now.getTime()}\`\n\n` +
22 `**Human-readable (UTC):** ${now.toUTCString()}\n` +
23 `**ISO String:** ${now.toISOString()}`
24 );
25 embed.setColor(getColor('success'));
26
27 await InteractionHelper.safeEditReply(interaction, {
28 embeds: [embed],
29 });
30 },
31 'Failed to get unix timestamp. Please try again.',
32 {
33 autoDefer: true,
34 deferOptions: { flags: MessageFlags.Ephemeral }
35 }
36 );
37 },
38};

Callers

nothing calls this directly

Calls 4

successEmbedFunction · 0.90
getColorFunction · 0.90
safeExecuteMethod · 0.80
safeEditReplyMethod · 0.80

Tested by

no test coverage detected