Workshop.DiscordBot 1.2.0

Build-A-Bot Workshop

This package provides the basic building blocks for creating a Discord Bot with Discord.Net.
Get your bot online with less than 5 lines of code. All you need to worry about is building your commands!

Install-Package Workshop.DiscordBot -Version 1.2.0
dotnet add package Workshop.DiscordBot --version 1.2.0
<PackageReference Include="Workshop.DiscordBot" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Workshop.DiscordBot --version 1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Build-A-Bot Workshop Build-A-Bot Workshop

Workshop.DiscordBot
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 the ServiceCollection.
  • 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's ModuleBase or from WorkshopModule, are automatically loaded into the provided CommandService.
  • Registering Type Readers: Custom Type Readers should be decorated with the TypeReaderAttribute.
    This allows them to be automatically added to the CommandService.

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.

Build-A-Bot Workshop Build-A-Bot Workshop

Workshop.DiscordBot
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 the ServiceCollection.
  • 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's ModuleBase or from WorkshopModule, are automatically loaded into the provided CommandService.
  • Registering Type Readers: Custom Type Readers should be decorated with the TypeReaderAttribute.
    This allows them to be automatically added to the CommandService.

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.

Version History

Version Downloads Last updated
1.2.0 80 4/19/2019
1.1.5 75 4/5/2019
1.0.5 74 3/31/2019