patrickklaeren / Accord

A C# Discord bot with moderation, XP/guild participation and utilities
MIT License
15 stars 8 forks source link
bot csharp discord dotnet

Accord

Accord Logo

Reach accord, prevent discord, on Discord.

A C# .NET 9 Discord bot with moderation, XP/guild participation and utilities aimed at all users within a guild. This is not a hosted bot, it is intended to be self hosted.

How do I contribute

Accord is actively developed with both Rider and Visual Studio 2022. It is recommended you use either IDE for a positive experience. However, Accord is built entirely on .NET and therefore works anywhere dotnet build can be executed.

You can grab an unassigned issue and comment on it to indicate your interest on championing it. Alternatively, if you have a suggestion for a new feature and want to champion this, create a new issue and it can be discussed in the repository.

Development ethos

Keep things short, simple and maintainable. No pointless abstractions or complicated chains. Move fast, break and innovate. This is a Discord bot first and foremost and it strives for simplicity.

What you'll need

How to get Accord running in development

By default the bot will look for a Postgres instance running on localhost. If your instance is not on localhost or has an otherwise differing connection string, set the ConnectionStrings:Database secret.

If you want to disable the Discord bot instance, for any reason, you can override Discord:DisableBot to true, which will only run the hosting ASP.NET Core project, skipping bot initialisation. Do note that several parts of the frontend require the bot to have a connection established.

Invite your bot

(Change your client Id to that of your application's)

https://discord.com/oauth2/authorize?client_id=CLIENT_ID&scope=bot%20applications.commands&permissions=1573252310

This ensures the bot has the minimum required permissions and can manage Slash commands on the guild.

Start the bot. This will apply migrations automatically via Entity Framework.

How to self host

You can build from source or host via the published Docker image. An example docker-compose.yml is below.

version: '3.1'

services:
  postgres:
    image: postgres
    restart: always
    environment:
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    ports:
      - '5432:5432'

  bot:
    image: ghcr.io/patrickklaeren/accord:main
    depends_on:
      - postgres
    restart: always
    environment:
      ConnectionStrings__Database: ${CONNECTIONSTRINGS_DATABASE}
      Discord__ClientSecret: ${DISCORD_CLIENTID}
      Discord__ClientId: ${DISCORD_CLIENTID}
      Discord__GuildId: ${DISCORD_GUILDID}
      Discord__BotToken: ${DISCORD_BOTTOKEN}
    ports:
      - '80:80'
      - '443:443'

Requirements

Set environment variables for ConnectionStrings:Database, Discord:GuildId, Discord:BotToken, Discord:ClientId, Discord:ClientSecret.

This bot is intended for single-guild usage.

Credits

Notable dependencies for this project include: