Convert to Typescript
This commit is contained in:
23
src/commands/taylor.ts
Normal file
23
src/commands/taylor.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { SlashCommandBuilder, ChatInputCommandInteraction } from 'discord.js';
|
||||
import taylorQuotes from './utils/constants/taylorQuotes.json';
|
||||
|
||||
// Initialise the command data.
|
||||
export const data = new SlashCommandBuilder()
|
||||
.setName('taylor')
|
||||
.setDescription('Returns a Taylor Swift quote.');
|
||||
|
||||
console.log(`Loaded ${data.name} command.`);
|
||||
|
||||
/**
|
||||
* Returns a random Taylor Swift quote.
|
||||
* @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 randomIndex = Math.floor(Math.random() * taylorQuotes.length);
|
||||
const response = taylorQuotes[randomIndex];
|
||||
|
||||
await interaction.reply(response);
|
||||
}
|
||||
Reference in New Issue
Block a user