Skip to content
This repository has been archived by the owner on Aug 6, 2019. It is now read-only.
/ HunieBot2 Public archive

A mini abstraction layer that rests on top of Discord.Net for bot creation and management.

Notifications You must be signed in to change notification settings

formlesstree4/HunieBot2

Repository files navigation

HunieBot

HunieBot is a small Discord Bot Framework built on top of Discord.NET that aims to make the initial startup cost of creating a Bot for Discord simple and easy by using Attributes to decorate classes, methods, and functions.

Getting started with HunieBot

HunieBot requires Discord.NET and optionally likes Discord.Net.Audio (if you prefer to use the built-in MusicStream bot). You also must understand .NET Attributes.

Now then, let's get started with creating your first bot for HunieBot.

Here's a simple class to get you started:

using HunieBot.Host.Attributes;
using HunieBot.Host.Enumerations;
using HunieBot.Host.Interfaces;
using System.Threading.Tasks;

namespace HunieBot.HelloWorld
{
    [HunieBot(nameof(HelloWorldBot))]
    public sealed class HelloWorldBot
    {
        [HandleCommand(CommandEvent.MessageReceived | CommandEvent.CommandReceived, commands: new[] { "ping" })]
        public async Task HandleCommand(IHunieCommand command)
        {
            await command.Channel.SendMessage("pong");
        }
    }
}

There's a lot going on in just 17 lines of code. Let's take a moment to break down what's going on, focusing in particular on two lines of code:

[HunieBot(nameof(HelloWorldBot))]

The HunieBotAttribute is an indicator for HunieBot that the class it is attached to is a Bot that must be instantiated and loaded at runtime. It has one required parameter and that is the name of your Bot.

The second Attribute has quite a bit more going on:

[HandleCommand(CommandEvent.MessageReceived | CommandEvent.CommandReceived, commands: new[] { "ping" })]

The HandleCommandAttribute is a bit more of an advanced Attribute that describes to HunieBot how your method call is to be invoked when a command is received. For the sake of brevity, please refer to the linked file for documentation and comments.

Running your HunieBot

By default, the HunieBot.Host project will scan whatever path is in Environment.CurrentDirectory to load assemblies that might contain HunieBotAttribute classes. That means building HunieBot instances is as simple as compiling a DLL and dropping it into the same folder that HunieBot.Host resides in.

Warning: This documentation is sparse and incomplete. I am working on documenting everything but it will take some time.

About

A mini abstraction layer that rests on top of Discord.Net for bot creation and management.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages