Workshop.DiscordBot
1.2.0
dotnet add package Workshop.DiscordBot --version 1.2.0
NuGet\Install-Package Workshop.DiscordBot -Version 1.2.0
<PackageReference Include="Workshop.DiscordBot" Version="1.2.0" />
paket add Workshop.DiscordBot --version 1.2.0
#r "nuget: Workshop.DiscordBot, 1.2.0"
// Install Workshop.DiscordBot as a Cake Addin
#addin nuget:?package=Workshop.DiscordBot&version=1.2.0
// Install Workshop.DiscordBot as a Cake Tool
#tool nuget:?package=Workshop.DiscordBot&version=1.2.0
Build-A-Bot Workshop
The Build-A-Bot Workshop is a quick and easy way for you to get started building your own Discord Bot.
Getting your bot online is as simple as:
Imports Workshop.DiscordBot
Namespace VB.Example
Module Program
Sub Main(args As String())
'Create an instance of DiscordBot.
'Provide the token file filename and a bot prefix.
Dim simpleBot = New DiscordBot(New BaseBotConfig("token.txt", "/"))
'Start the bot!
simpleBot.StartAsync().GetAwaiter().GetResult() 'Log-in & connect to Discord
End Sub
End Module
End Namespace
using Workshop.DiscordBot;
namespace CSharp.Example
{
class Program
{
private static void Main(string[] args)
{
//Create an instance of DiscordBot.
//Provide the token file filename and a bot prefix.
//Call StartAsync to log-in and connect to Discord
new DiscordBot(new BaseBotConfig("token.txt", "/")).StartAsync().GetAwaiter().GetResult();
}
}
}
Your bot is now onine and listening for commands (any message prefixed with /
, for this example, or a bot mention).
NOTE!
This project uses the Discord.Net wrapper for interfacing with the Discord API.
So, it'll propbably be a good idea to get familiar with their documentation for actually creating your commands.
That said, there is a WorkshopModule
that can be used to replace Discord.Net ModuleBase
and extend the command module funcationality.
Getting Started
Installation
Release builds are available from Nuget
Initial Visual Studio Project
- Create a new project (preferably a .Net Core Console Application)
- Install the Workshop.DiscordBot nuget package via the Visual Studio Packet Manager
- Follow the code snippet above to get connected
- Profit?
Take a look at the Examples provided.
SampleBot_Basic should be enough to give you an idea of adding commands
, services
and custom typereaders
(if needed).
Things to Note
Auto-magic management
- Dependency Injection: An
IServiceProvider
is included for storing and retrieving services. - Adding Services: Classes decorated with the
ServiceAttribute
are automatically loaded into theServiceCollection
. - Initializing Services on Startup: The
InitializeAttribute
can be used to instantiate a service on startup (if necessary). - Adding Commands: The Discord.Net Command Service is the expected approach for creating commands.
All modules tha inherit from either Discord.Net'sModuleBase
or fromWorkshopModule
, are automatically loaded into the providedCommandService
. - Registering Type Readers: Custom Type Readers should be decorated with the
TypeReaderAttribute
.
This allows them to be automatically added to theCommandService
.
Command Module Extension
The WorkshopModule
overrides the ModuleBase
provided by Discord.Net and includes additional helper methods for working with commands.
Utilizing the InteractiveService
from Discord.Addon.Interactive, the WorkshopModule
also assists with adding interactivity to your bot commands.
Basic methods are provided for both interactive messages and interactive reactions. See the SampleBot_Interactive for usage examples.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 is compatible. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
-
.NETCoreApp 2.0
- Discord.Addons.Interactive (>= 2.0.0-dev-00011)
- Discord.Net (>= 2.0.1)
- Microsoft.Extensions.DependencyInjection (>= 2.2.0)
- Workshop.PluginsManager (>= 1.1.0)
- Workshop.Tools (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|