A very simple Discord bot made with TypeScript & discord.js version 14.
Install typescript
globally:
npm i -g typescript
Install all the required dependencies:
npm i discord.js@14 dotenv
Rename the file .env.example to .env and fill all the required properties.
Warning If you are using repl.it, delete the .env file and use Secrets instead.
To compile the TypeScript files to JavaScript files & run the compiled files, use the command below:
npm run build
or, start the old compiled JavaScript files:
npm run build-start
The class SlashCommandBuilder
is from the library @discordjs/builders.
export default new Command({
command_data: new SlashCommandBuilder()
.toJSON(),
options_data: {
owner_only?: boolean
},
run: (client, interaction, args) => { }
});
You can click here to understand how TypeScript compiler works.