A simple library to facilitate the construction of bots for Discord using the C# language, DSharpPlus library and .NET Standard 2.0.
Installing
- Install the library through NuGet, if you only wanted the basics to start the bot, download only the "Tars" package.
Getting Started
- Create a project in Visual Studio, preferably in .NET Core, version 2.0 or later.
- Change the Main method from void to async Task.
- If red lines appear in the code, click on it and press
Ctrl
+.
and add the missing usings, do it the other times you need. - In your bot's main, just write this:
static async Task Main(string[] args)
{
var botBase = new TarsBase(Assembly.GetEntryAssembly());
botBase.DiscordSetup("Your bot's token");
botBase.CommandsSetup(new string[] { "A prefix of your choice" });
await botBase.StartAsync();
}
- If you start the bot by another class and methods that are not static, you can put the bot class as a service, to access it via commands, this is how it is added:
botBase.CommandsSetup(new string[] { "A prefix of your choice" }, services: new ServiceCollection().AddSingleton(this));
-
And ready! If everything goes as expected, your bot will go online :)
-
This tutorial is just the basics to create a bot, to see more Tars functions, click here.