Convert to Typescript
This commit is contained in:
22
src/commands/servertime.ts
Normal file
22
src/commands/servertime.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { SlashCommandBuilder, ChatInputCommandInteraction } from 'discord.js';
|
||||
import { format } from 'date-fns';
|
||||
|
||||
// Initialise the command data.
|
||||
export const data = new SlashCommandBuilder()
|
||||
.setName('servertime')
|
||||
.setDescription("Returns the server's current time.");
|
||||
|
||||
console.log(`Loaded ${data.name} command.`);
|
||||
|
||||
/**
|
||||
* Replies with the server's current time.
|
||||
* @param interaction The interaction that triggered the command.
|
||||
* @returns A promise that resolves when the command is finished executing.
|
||||
*/
|
||||
export async function execute(
|
||||
interaction: ChatInputCommandInteraction
|
||||
): Promise<void> {
|
||||
const now = new Date();
|
||||
const formattedTime = format(now, 'dd/MM/yyyy HH:mm:ss');
|
||||
await interaction.reply(`The server's current time is: ${formattedTime}`);
|
||||
}
|
||||
Reference in New Issue
Block a user