Creating a slash command - synthofficial/discord-idle-game-bot-template GitHub Wiki
Creating a Slash Command
The slash command is strongly typed, and is formatted as below.
import { ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js";
import { SlashCommand } from "../types";
export default {
command: new SlashCommandBuilder()
.setName("ping")
.setDescription("Returns the API latency."),
execute: async(interaction : ChatInputCommandInteraction) => {
await interaction.reply(`Pong!\n${interaction.client.ws.ping}ms!`);
}
} as SlashCommand;
To import prisma in a slash command, you can import it.
import { prisma } from "../Client/database";