Skip to content

Creating Bots

Raul-Sorin Sorban edited this page Jun 15, 2019 · 5 revisions

The first step at creating Bots fast and easy (as promised), is to quickly understand and follow the Wiki docs for PTGen.exe, which generates a whole quick-start project for you.

After the Bot project is generated, you can override certain properties and functions. But firstly, you'll have to set up the informations attribute accordingly.

[Informations ( Name = "botname", ID = "botid", Prefix = '!', Version = "0.1.0" )]

Overrides

Most important overrides are user-friendliness related. Such as the Contact, Help, RegisterMods, UninitializeMods, (etc.) overrides.

  • override string MainChannel: The Bot's 'home' Discord channel ID, where it can return major error messages issues when debug-mode is on, or whatever.
  • override Contact Contact: Contact information when someone calls the "info.contact" command, which contains the developer user discord ID, contact user ID (most likely the same) and an contact Email.
  • override string Help: It's a text filled (limited to 2000 characters - according to Discord's policy) with information about the bot, it's functionality or your pornhub account link. Used to help people.

The other overrides are functions, but most of them are self explanatory. Be sure to execute the base method when overriding too (to avoid issues).

The way Bots talk to Mods is extremely simple and fast. You just need to have a reference to the Mod project or DLL firstly. In order to register a mod for runtime execution, after you've done that you'll need to override the internal BaseBot function public override void RegisterMods () (of course, in the bot class).

For example:

public override void RegisterMods ()
{
     AddMod ( new TestMod () );
}

In the backend, a new instance of this specific mod will execute and Megabot will act accordingly (since Megabot supports runtime updating and keep-alive functionality).

Default Commands

For more ease, I wrote a bunch of Commands which any sort of Bot would use (if you're enabling it to). They are meant to print information, enable management on the server side through a client but ONLY to users which are Administrators or have the Developer ID set in the bot. It autosaves (the bot and bot mods) over a period of time or executed through a command).

Overall commands look like this:

bot Factory

  • bot.playing: Playing activity name displayed under the bot's user profile. (Admin-Only)
  • bot.listening: Listening activity name displayed under the bot's user profile. (Admin-Only)
  • bot.streaming: Streaming activity name displayed under the bot's user profile. (Admin-Only)
  • bot.watching: Watching activity name displayed under the bot's user profile. (Admin-Only)
  • bot.status: Bot's user status. (Admin-Only)

commands Factory

  • commands.printbotcommands (or commands): Print all commands for this bot.
  • commands.printmodcommands (or modcommands): Print all commands for this bot.
  • commands.find (or find): Filters commands for this bot.

general Factory

  • general.save (or save): Saves the Bot and currently live Mods. (Developer-Only)
  • general.load (or load): Loads the Bot and currently live Mods. (Developer-Only)
  • general.shutdown (or shutdown): Ends this session of the bot. Saves everything and quits safely. (Developer-Only)
  • general.debugmode (or debug): Enables/disables certain features for the Bot or Mods. (Developer-Only)
  • general.restart (or restart): Shuts the bot down then restarts it. (Developer-Only)
  • general.quit (or quit): Shuts the bot down followed with the console. (Developer-Only)

info Factory

  • info.help (or help): Prints GlobalBot's help information text.
  • info.bot: Information about the Bot's connectivity and current status. (Admin-Only)
  • info.user: Information about the user in general.
  • info.server: Information about the server.
  • info.developer: Information about the developer of this GlobalBot.
  • info.contact: Information about the contact user of this GlobalBot.

purge Factory

  • purge.all: Attempts to remove all current messages in this channel. They cannot be removed if older than a week. (Admin-Only)
  • purge.few: Removes a number of messages from this channel. (Admin-Only)

Pretty friendly, huh?

This page will eventually be updated in the future. There's just a lot of features (like discord callbacks, server, complex logging). It's all there, so when you create a mod or a bot, you'll find all usable methods. They have been carefully written, so private/internal methods don't show up, so it's not a mess to look through by yourself.

I'm very Issue friendly and I am absolutely sure there are bugs/exploits, so do not input any sort of minor thing that's been bugging you out.