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!
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.
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.
- To manage storage of the needed
Discord Bot Token
andDatabase Connection String
, and other important project configuration/settings, Silk uses anappSettings.json
file.
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
- 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 thePassword
key a value (password for the Postgres user).
-
- 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.
- 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
-
-
The alternative, and more recommended way (but still NOT suitable for
Production
) for managing the configuration file is usingUser 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
- Windows
-
In the
Silk.Core
project, aUserSecretsId
property is defined in theSilk.Core.csproj
file which looks like this:-
<UserSecretsId>VelvetThePanda-SilkBot</UserSecretsId>
-
-
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!
- Just copy what's in that template and paste it in the
-
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!
-
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
-
-
If you're using Visual Studio, you can use the
Package Manager Console
. Note: Make sure in the tool window, to change theDefault project
tosrc\Silk.Core.Data
. Then execute the following command:-
Update-Database
- You can install the
Package Manager Console
tools by following this document Entity Framework Core Tools - Package Manager Console in Visual Studio
-
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.