3.1.8-dev • Published 4 years ago
typescript-discord v3.1.8-dev
Discord.js bot setup with typescript
I'm french but my english is bad, this readme contains only exemples to use Sucrose structure
This is a Typescript Discord bot structure
Documentation
Table of contents
commands | descriptions |
---|---|
$ npm run build | build for production |
$ npm start | start bot with ts-node in development |
$ npm run start:prod | build and start in production |
$ npm start:respawn | development start with automatic restart |
Getting started
steps | |
---|---|
1 | Configure environment |
2 | Create your first event |
3 | Create yout first command |
# Configure environment
Create .env file in base of project
NODE_ENV="development"
TOKEN="Your discord bot token"
NODE_ENV:
- "development" to launch with typescript
- "production" for configure to prod version
TOKEN:
Get your discord.js bot token in your discord application:
ATTENTION: Your token is secret, do not share it
# Create your first event
Create ready folder and this handler
- src
- events
- ready
- handler.ts
Fill in the events/ready/handler.ts file
/* Typings */
import { Params } from 'src/structures/typings';
/* Listener */
export default async ({ sucrose }: Params<'ready'>) => {
console.log('I love ferret');
};
# Create your first command
Create your command file in global (or a guild folder)
- src
- commands
- global
- hi.ts
Fill in the commands/global/hi.ts file
/* Typings */
import { Command } from 'src/structures/typings';
export default <Command>{
body: {
name: 'hi',
description: 'Say hi',
},
exec: ({ interaction }) => {
interaction.reply('Hiiii !');
},
};