Example taken from https://github.com/oceanroleplay/discord.ts-example
Relevant links:
- https://discord-ts.js.org/docs/installation
- https://discordjs.guide/preparations/ (and following pages)
Determine scope of bot.Integrate within Discord serverDecide Framework.TypeScript, with SQLLite DB- Implement working base bot.
- Get a prod bot on Banana Discord
- Create and connect SQLLite DB to bot/bot code. (Separate prod/dev dbs?)
- Start-to-finish documentation for setup and new devs.
- List of commands to implement
- Investigate merging with current BrexBot implementation, including potential account ownership/transfer.
Reach in the #bot-development channel in the Discord for questions on joining the project.
The bot uses the Prisma ORM for persistence. By default this uses SQLite.
See the duel commend for database integration examples.
The schema for the Database is stored in the Prisma schema file.
Create the client definition
npx prisma generate
Create a new empty Database for development
npx prisma migrate dev --name init
Open the file with sqlite
sqlite3 prisma/dev.db
For better output in sqlite enable columns and headers. You can also hardcode these settings in the ~/.sqliterc file.
sqlite> .mode column
sqlite> .headers ON
Prerequisites:
- Recent version of Docker
Build the image
docker build -t brexbot .
Create a .env file which contains the bot token
DISCORD_TOKEN=<token>
Start the container
docker run --rm --env-file.env -ti brexbot
Prerequisites:
- Node.js >= 16
Install the dependencies
npm install
Export the bot token as an environment variable
# Bash and similar
export DISCORD_TOKEN=<token>
# Powershell
$Env:DISCORD_TOKEN = "<token>"
Run the bot
npm run start