Development · Downloadables · Programming · Project

Megabot

Additional Features

Had an interest in coding an animation system for the console. It has nothing to do with the Discord hosting, it’s just console-only commands that are fun to play around in the interface. Frames are drawn, set the speed of the animation and has different types of playing them (e.g boomerang effect, reverse playback).

Docs & Tutorial

For both cases, you must create a Class Library (.NET Framework) (for .dll output) project – or as I advise, a Solution for multiple bots or mods.

Be sure your projects have these references:

  • Megabot.Data.dll
  • Megabot.Console.dll

Both bots and mods have the same command structure. To add one or more command factories, use the following code example and just place the .cs file in a Commands dedicated folder (not a must, but clean project, clean life).

<write this in the updated version at home>

Create a Bot

Rename the Class1 to your bot’s name or whatever you want then add using Megabot.Base; namespace. Inherit the class with BaseBot<classname> and now to define your bot’s informations, you must add the Informations attribute on top of the class, which is under using Megabot.Base.Bot.Attributes; namespace.

[Informations(Name = "Botchael", ID = "botchael", Prefix = '!', Version = "4.2")]

If you didn’t yet understand what the parameters mean, here’s few notes:

  • ID is the internal name of the bot, used to start it using the “start <bot id>” command.
  • Version it’s just to keep track of differently updated versions of a bot, if ever thought about releasing it to the public or something.
  • Name is the display name of the bot.
  • Description is a shorter explanation what the bot is for and do. Keep the details for Help override.
  • Prefix is the one or many symbols/numbers/whatevers which declare that it’s the start of a command in the Discord chat area. Recommended something like ! or ?.

Within the class, you can override the following (important) methods/properties:

  • Contact, which has ContactUserId (discord ID), DeveloperUserId (discord ID) and email.
  • Help is a text (string) property in which you just type what it will render when anybody on a Discord Server would type (prefix)help.
  • Main Channel is a channel name in a Discord Guild/Server. Not always important, it’ll be removed eventually.
  • Register Mods is the function which does what it says. Using AddMod(new Mod());, will basically launch the bot with the defined mods.
  • Initialize is important when you want the mod to do certain processing before full startup.
    (Be sure you also run the base method.)
  • ShutDown is executed when the bot is shut down.
    (Be sure you also run the base method.)
  • InitializeMods is ran usually when the bot starts up. (Be sure you also run the base method.)
  • UninitializeMods is executed when the bot is shutting down. (Be sure you also run the base method.)
  • Load(quiet) is the method which on it’s base call, executes loading the .main file of the bot. You can override it and add stuff you wanna load with the bot, but be sure you also call base.Load(quiet); in the method.
  • Save(quiet) is the method which executes saving the .main file of the bot. You can override it and add stuff you wanna save with the bot, but be sure you also call base.Save(quiet); in the method.
public override void RegisterMods()
{
AddMod(new IAmGame());
AddMod(new CoinsMod());
AddMod(new StoreMod());
AddMod(new TicTacToeMod());
AddMod(new GamblingGame());
}

Create a Mod

Rename the Class1 to your mod’s name or whatever you want then add using Megabot.Base; namespace. Inherit the class with BaseMod<classname> and now to define your mod’s informations, you must add the Informations attribute on top of the class, which is under using Megabot.Base.Mod.Attributes; namespace.

[Informations(ID = "iam", Name = "I Am", Description = "It's so fun, you'll not be able to can even.", Version = "1.0")]

If you didn’t yet understand what the parameters mean, here’s few notes:

  • Name is the display name of the bot.
  • Description is a shorter explanation what the bot is for and do. Keep the details for Help override.
  • Version it’s just to keep track of differently updated versions of a bot, if ever thought about releasing it to the public or something.

Within the class, you can override the following (important) methods/properties:

  • Contact, which has ContactUserId (discord ID), DeveloperUserId (discord ID) and email.
  • HowToUse is a bad name property which is pretty much same as Help property in the BaseBot<T>.
  • Initialize is important when you want the mod to do certain processing before full startup.
  • Uninitialize is executed when the bot is shut down.
  • Load(quiet) is the method which on it’s base call, executes loading the .main file of the mod. You can override it and add stuff you wanna load with the mod, but be sure you also call base.Load(quiet); in the method.
    Save(quiet) is the method which executes saving the .main file of the mod. You can override it and add stuff you wanna save with the mod, but be sure you also call base.Save(quiet); in the method.

As soon as I’ll create the build story of Megabot, you’ll be able to download it from here:

Downloads

One thought on “Megabot

Comments are closed.