Giggitybyte / Silk

Small bot with big ambitions! Features the community wants without the bloat.

Home Page:https://velvetthepanda.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Silk!

Silk is a simple and the fastest Discord bot written in C# until proven otherwise. Silk is built on top of the DSharpPlus .NET Discord library, with the goal to not only be a great bot but to also fill in the gaps that some bots have. Silk aims to be a bot your members will want to use, while not being a cookie-cutter game, moderation, or entertainment bot. Silk is also made with large guilds in mind. Feel free to join the Silk! Server to ask any questions you may have or any general support you may need. Want this bot on your server? Feel free to invite it!

Code Quality Code Size Lines of Code GitHub Closed Issues Discord


Development

Silk! is an open-source bot, and if you know C#, you're more than welcome to contribute! If you're on the server, and your PR gets merged, you get a nice light blue role on the server to signify your contributions. Active contributors are given a special role as well.

Resources


Database

Silk uses PostgreSQL for its backend database store. So if you don't have PostgreSQL installed, make sure to install it before trying to run the Visual Studio solution.


Configuration / Secrets Management

  • To manage storage of the needed Discord Bot Token and Database Connection String, and other important project configuration/settings, Silk uses an appSettings.json file.

Default

When you clone Silk, before running the project, you'll need to edit the template appSettings.json file in the following directory: src\Silk.Core


  1. For the Database, look for the Persistence section of the file, it will look something like this:
    •  "Persistence": {
          "Host": "localhost",
          "Port": "5432",
          "Database": "",
          "Username": "postgres",
          "Password": ""
       }
    • From there, just give the Username key a value (database name), and the Password key a value (password for the Postgres user).

  1. Now for the Discord Bot Token, look for the Discord section of the file, it will look something like this:
    • "Discord": {
         "Shards": 1,
         "ClientId": "",
         "ClientSecret": "",
         "BotToken": ""
      }
    • From there, just give the BotToken key a value (your Discord Bot Token)
      • If you don't have your token off-hand, you can get it from the Discord Developer Portal; Select your application once logged in, then select Bot in the menu, and you should be able to Reveal your token from there.

App Secrets

  • The alternative, and more recommended way (but still NOT suitable for Production) for managing the configuration file is using User Secrets

  • The advantage of using User Secrets, is that the file is stored in a separate location from the project tree. Because of this, those secrets aren't checked into source control.

  • The location of the secrets.json file is different between Operating Systems, but it's stored in a system-protected user profile folder on your computer.

    • Windows
      • %APPDATA%\Microsoft\UserSecrets\VelvetThePanda-SilkBot\secrets.json
    • Mac / Linux
      • ~/.microsoft/usersecrets/VelvetThePanda-SilkBot/secrets.json
  1. In the Silk.Core project, a UserSecretsId property is defined in the Silk.Core.csproj file which looks like this:

    • <UserSecretsId>VelvetThePanda-SilkBot</UserSecretsId>
  2. The structure for the file is the same for the Default - appSettings.json approach

    • Just copy what's in that template and paste it in the secrets.json file. Then fill in the needed pieces and you're good to go!

Running the Project

  • If you're starting fresh, just cloned the repo, then you'll need to make sure you've done the needed Configuration, before running or debugging Silk.

  • If you're already using Silk, you may need to do any or all of the following to ensure that you have everything you need to run the latest and greatest!

Update your PostgeSQL database to the latest migration

  1. If you have dotnet ef command line tools installed, you can run the following command in the root folder of Silk to apply the latest migration.

    • dotnet ef database update -s Silk.Core -p Silk.Core.Data --verbose
      
    • You can install the dotnet ef command line tool by following this document Entity Framework Core Tools CLI
  2. If you're using Visual Studio, you can use the Package Manager Console. Note: Make sure in the tool window, to change the Default project to src\Silk.Core.Data. Then execute the following command:



⚠️ A NOTE ABOUT SELF-HOSTING ⚠️

Self-hosting Silk! is easy. Instructions have been provided to self-host locally.

Docker:

To run Silk! as a docker container, you can simply create an appSettings.json file in the root directory, and run docker pull velvetthepanda/silk, assuming you have a postgres database running already. If not, you can download a pre-configured docker-compose file here.

Both Postgres and Silk! will have to initialize on the first run, which may cause slightly degraded startup times as Silk! creates requisite tables on the database.

Further startup times should be no more than ~3 seconds to fully initialize and do cache runs.

About

Small bot with big ambitions! Features the community wants without the bloat.

https://velvetthepanda.dev

License:Apache License 2.0


Languages

Language:C# 99.9%Language:Dockerfile 0.1%