https://github.com/glowstudent777/discord.net-template
A .Net 7 Discord Bot Template
https://github.com/glowstudent777/discord.net-template
csharp discord discord-bot discord-net
Last synced: 11 months ago
JSON representation
A .Net 7 Discord Bot Template
- Host: GitHub
- URL: https://github.com/glowstudent777/discord.net-template
- Owner: Glowstudent777
- License: apache-2.0
- Created: 2023-06-01T20:20:56.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-17T14:52:09.000Z (about 2 years ago)
- Last Synced: 2025-07-19T05:37:57.563Z (12 months ago)
- Topics: csharp, discord, discord-bot, discord-net
- Language: C#
- Homepage:
- Size: 117 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Discord.Net Template
This is a Discord bot template made in C# using .Net 7
### Features
- [x] Dockerized
- [x] Database
- [x] Organized Layout
- [x] Nice Logs
- [x] Cron Jobs
## Cloning
Just a simple command in the terminal of your choice
```
git clone https://github.com/Glowstudent777/Discord.Net-Template.git
```
## Configuration
### Setting the Token
1. Get your Discord bot token from the [Discord Developer Portal](https://discord.com/developers/applications).
2. Rename `.env.example` to `.env` using the following command:
```sh
mv .env.example .env
```
3. Add your token to the `.env` file. This can be done using this command: `sudo nano .env`. Paste your token after `TOKEN=`. Lastly save the file using Ctrl+X, then Y and finally Enter.
## Docker
You will need to have Docker installed for this, if you don't have it set up, [here is a guide](https://docs.docker.com/engine/install/debian/#install-using-the-repository).
After you have installed and set up Docker run the following command:
```sh
docker compose up -d --build
```
# Development
I suggest using [Visual Studio](https://visualstudio.microsoft.com/) for this project.
## Changing Project Name
If you change the project name from `Houston` to something else make sure to update these files with your new name.
- [docker-compose.yml](docker-compose.yml)
- [src/Houston.sln](src/Houston.sln)
- [src/Houston.Bot/Dockerfile](src/Houston.Bot/Dockerfile)
- OPTIONAL if you want the GitHub Workflow, [.github/workflows/docker-image.yml](.github/workflows/docker-image.yml)
## Environment Variables
| 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.
1. Right click the `Xxx.Bot` project and select `Properties`
2. In the menu on the right side, go to `Debug`
3. Select `Open debug launch profiles UI`
4. Add `TOKEN` and `DATABASE` to the `Environment variables` section
## Database
You'll need to fire up a [Postgresql](https://www.postgresql.org/) 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
```
## Building
Build the bot and restore the dependancies using the `dotnet` command.
```
dotnet restore && dotnet build
```
## Running the Bot
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.
# Contributing & Licensing
Contributions are welcome. Please read the full conditions surrounding contributing in the [LICENSE](LICENSE) document before sending in your contributions.