RobotOverlords is a discord bot written in dotnet core 3 using discord .net.
- Microsoft.NETCore.Platforms
- Discord .Net
- Microsoft.Extensions.Configuration.CommandLine
- Microsoft.Extensions.Configuration.Json
- Microsoft.Extensions.Options.ConfigurationExtensions
- Microsoft.Extensions.DependencyInjection
- Microsoft.Extensions.Hosting
- Microsoft.Extensions.Logging
- Microsoft.WindowsDesktop.App
- System.ServiceProcess.ServiceController
This solution has minimum functionality and is meant to be a template to quickly stand up custom bots with.
https://docs.microsoft.com/en-us/dotnet/core/
- Create a discord developer account, a bot, and obtain a bot token here: https://discord.com/developers/applications
At the end of this, you should have an api key, a registered application with a registered bot, and your bot should be added to a server.
- Populate .\RobotOverlords\appsettings.json botConfiguration.apiKey with the newly created discord key.
- Run
dotnet restore
on the solution - Run the solution from visual studio and confirm that the bot logs in.
Posting the message !info in a channel the bot can see should cause the bot to response with information about itself.
- Create a new class in RobotOverlords.Modules, follow the *Module.cs naming convention
- Inherit from Discord.Commads.ModuleBase
- Implement command logic.
- Register command with the following method attribute:
using Discord.Commands;
[Command(""), Summary("")]
where the command's trigger is !{{Command}}
- Place the model class into RobotOverlords.Modules.Models
- Access via using declarations
-
Place service class into RobotOverlords.Modules.Services
-
Register service class in RobotOverlords.Modules.Services.ModuleServiceCollectionBuilder(), this adds the service to an IServiceProvider that is dedicated to RobotOverlords.Modules at Startup.
-
Access via constructor injection.
See how RobotOverlords.Modules.Services.InfoService is injected into RobotOverlords.Modules.InfoModule
- Event handling occurs in RobotOverlords.Observers
- Changing Observer classes will change how events emitted by the DiscordSocket client are delegated.
Like everyone else in existence: //TODO: Implement Unit Tests.
dotnet build
in the .sln directory