This is a Discord bot template made in C# using .Net 7
- Dockerized
- Database
- Organized Layout
- Nice Logs
- Cron Jobs
Just a simple command in the terminal of your choice
git clone https://github.com/Glowstudent777/Discord.Net-Template.git
- Get your Discord bot token from the Discord Developer Portal.
- Rename
.env.example
to.env
using the following command:
mv .env.example .env
- Add your token to the
.env
file. This can be done using this command:sudo nano .env
. Paste your token afterTOKEN=
. Lastly save the file using Ctrl+X, then Y and finally Enter.
You will need to have Docker installed for this, if you don't have it set up, here is a guide.
After you have installed and set up Docker run the following command:
docker compose up -d --build
I suggest using Visual Studio for this project.
If you change the project name from Houston
to something else make sure to update these files with your new name.
- docker-compose.yml
- src/Houston.sln
- src/Houston.Bot/Dockerfile
- OPTIONAL if you want the GitHub Workflow, .github/workflows/docker-image.yml
Key | Required | Default |
---|---|---|
TOKEN | True | None |
DATABASE | True | None |
If you don't know how, here is how you enter environment variables in Visual Studio for local testing.
- Right click the
Xxx.Bot
project and selectProperties
- In the menu on the right side, go to
Debug
- Select
Open debug launch profiles UI
- Add
TOKEN
andDATABASE
to theEnvironment variables
section
You'll need to fire up a Postgresql database and grab it's connection details.
If your database isn't running locally you'll need to replace localhost
with the server ip/hostname.
Key | Input |
---|---|
Server | IP or hostname |
Port | Usually 5432 |
UserId | Database username |
Password | Database password |
Database | database you're using for the bot |
Server=localhost;Port=5432;UserId=admin;Password=securepassword;Database=superdb
Build the bot and restore the dependancies using the dotnet
command.
dotnet restore && dotnet build
In Visual Studio you'll find two buttons at the top; a solid green start button with the text Xxx.Bot
and one next to it that has a green outline without text. The solid green with text is for debugging and the one without starts without debugging.
Contributions are welcome. Please read the full conditions surrounding contributing in the LICENSE document before sending in your contributions.