if you want to skipt the setup part scroll to the bottom to see available scripts a
if you don't already have yarn install it with:
npm install --global yarn
now install dependecies
yarn install
copy the example.env
file and name it .env
and put in your token and id
first create a copy of the !template.ts
file located in src/commands/
and call it something of your chosing. Set the name and description, and fill in your code.
example: (do note the example code is already implemented)
...
export default {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with Pong!'),
async execute(interaction:ChatInputCommandInteraction) {
await interaction.reply('Pong!');
},
} as Command
add your command to the commands.ts
file located in src/
example:
import ping from "./commands/ping";
export const Commands: Command[] = [ping]
the last step before actually running the bot, tell discord what commands we have
yarn run deploy
if you want to make guild specific commands you have to edit the deploy-commands.ts
file located in src/
starting the bot can be done in two ways with or without nodemon
starts the bot with nodemon
yarn run watch
starts the bot normaly
yarn run start
if you are getting erros you souldn't be getting try restarting the TS language server:
F1 → >Typescript: Restart TS server
starts the bot with nodemon
yarn run watch
starts the bot
yarn run start normally
this command updates the slashcommands on the discord side
yarn run deploy
if you have the eslint extention (vscode) you probably wont need this:
yarn run lint