Omega Discord Bot DevLog (Devember 2019)

Omega is a discord bot I have written in javascript running on Node.js, using MongoDB to allow extensions to format their own documents for database storage. Omega is more or less a framework to allow quick and easy implementations of bot funtionality using the discord.js library for node applications.

Omega handles the guilds (discord servers) and database interactions through modules and toolkits that the extensions can use. The extensions are added and initialized on runtime, and each guild connected to the Omega bot gets their own instance of the extension, so that all data is separated.

Current features of Omega:
Support for multiple guilds in a single instance of the bot.
Fully extensible, extensions are loaded on runtime.
MongoDB intergration that allows for simple database interaction for extensions.
Permission system that utilizes discord roles and permission powers for gating access to bot commands.

What I might plan to do this devember:
I haven’t spent time working on Omega for months now. I moved cities, started a new job, and so on. There is a lot that needs to be done with Omega. Shit code that needs to be redone, features that need to be implemented, and error checking across the board.

5 Likes

December 1, 2 and 3

Haven't had much time for coding the past few days, but I have spent my time for the devember reading up on documentation for TypeScript. I will be rewriting Omega in typescript, and since I have only coded in javascript before I need to familiarize myself with TypeScript before getting into the rewriting. Hopefully I will have more time going forward to read and code, but december is a bussy month.

Very exited about having started with this, been thinking of doing this for quite some while, and now I have a good excuse to get started.

Will set up a github/gitlab page when I have rewritten the basic functionality that makes omega work.

2 Likes

I’ll help test if you need it. Looks like a neat project. Any special features that the current offerings dont do?

1 Like

Supposed to be simple to add additional functionality to by being completly modular. Need a poll bot? Write quick easy code for that. Need a bot that manages settings - just write a simple extension for it. Omega handles anything relating to server management and permissions. I also have plans to build a GUI for it.

It was originally written because my FFXIV Free Company (guild) needed a reaction based poll bot for discord to decide on events, and it needed to be able to track the reactions in real time to decide if someone who voted already had voted for something else, in which case it would remove the old vote.

The original bot I wrote for it was messy and only supported single servers. When we started wanting more stuff from it, and also wanted to use it on multiple servers, I wrote omega, and then rewrote the original bot as an extension to Omega.

4 Likes

I’ll give you a link so you can add the OmegaBeta bot to a discord server of your liking when it is up and running again.

3 Likes

December 4th - Planning out the changes

The rewrite of the bot has commenced. I have started laying out the groundwork for improvements to the basic workings of the bot, to make it more efficient and scalable, and also easier to use.

Once the code is more than just comments and logging to check that things are working, I will set up a git for it, hopefully that is tomorrow. :stuck_out_tongue:

3 Likes

December 5th - Discord events and handeling these

The gitlab page is live, the code is still just a skeleton, but I am starting to get an idea of how I will alter the original design of the bot to make it more flexible.

The original Omega utilized the nicely formatted events supplied by the Discord.js library for handling different type of discord events. This was nice because you knew exactly what information would be in the event packet and this made it easy to handle them.

The problem is that Omega is meant to work on multiple servers, and all discord events are sent through the common bot interface, and needs to be redirected to the correct guild and if any extensions in use will react to that particular event, the correct extension.

The old way Omega handled this was declaring and redirecting the supported event types of the bot at the time. But this requires there to be a client.on('event', async (packet) => {}); for every single interesting event. And since there are a lot of possible events I don’t want to write a single function for every single event to forward said event to the correct guild and so on.

The old omega had this architecture using preformated events:
Discord Emits Event -> Omega recieves preformated event -> Redirects specific event to specific event handler in the guild object -> Guild object redirects to extensions that "listen" for specified event -> extension does work.

The new way this will work is still the same in that Omega needs to redirect the events to the correct guild, which then hands them out to the relevant extensions. But instead of writing specific funtions for every single type of event, I will be using the raw event type. The raw event type in Discord.js is the unformated raw event packet that is emitted from discord. This packet contains information about what event it is, in addition to which guild sent it.

All omega will do is::
1 - Check if the guild is an initialized guild with corresponding guild object
2 - Send the entire packet over to the correct guild to resolve the event.

This is benificial because we no longer need to write new code for multiple modules to add a single new event type. Instead the event type and important data will be resolved on the guild level only.

I’m thinking of implementing simple ways for extensions to utilize the most common events, but because all events emited by a specific guild are forwarded to that guilds instance in omega (except events that are to be handled directly by Omega and not be exposed to extensions), I will also make a option for extensions to get the raw discord packet so it will allow extensions to utilize and work on all events emitted by the discord guild.

Anyways, I will be very bussy with work tomorrow, hope I can find some time to work more on this by the evening.

3 Likes

December 6th

Spent the evening working on the way the bot handles events and commands. Got the rough method worked out. Comitted the latest code.

No major funtionality added yet, except that it now indexes and initialized the guilds in a basic guild object that contains information about the guild they represent.

For now it just logs in the console if an event occured and of what type it was.

But progress is being made! Looking forward to tomorrow, no work during the weekends, so hopefully I will get a few hours of coding in.

3 Likes

Nice man, looks like you’re putting in a decent amount of work. Keep it up!

1 Like

December 7th

Today’s work is on the git lab. The latest changes haven’t been tested because the Discord API is down, and won’t allow me to log in. But it does not do much yet anyways.

I set up an Extension class that all extensions need to inherit from. Also set up the basic structure of an extension and how it interfaces with the bot. This is accompanied with an example extension that will implement some functionality of some kind to demonstrate how to write a simple extension for the bot.

Nothing is finished yet, especially since I still need to implement a database system for a unified information storage system. I will start work on this when standard extension loading is working.

1 Like

December 28th - Catching up on all the lost days

So.... Life happened, and I found myself with little time to work on my devember project. Between cathing the flu, work, and heading out of town for christmas I didn't get to do much work.

…So I spent today writing code for about 6 hours. xD

So What did I get done now?
Quite a lot actually.

What was accomplished today:

  • Omega now imports extensions from an extension folder on runtime
  • All events are now propely handled and forwarded to extensions if there are any extensions listening for them
  • Omega can now accept commands from messages using a “bot command” followed by a “namespace” for the corresponding extension. For example: bot_command!namespace command arguments
  • In the case a message is a command omega now runs the message through a function that splits up the namespace, command and arguments and stores them in an array that then is forwarded to the correct extension.
  • Guild settings has been decided to all be contained inside a JS object that will be stored as a document in a mongoDB. This will simplify storage of guild settings. Since work on database integration has not been started yet, a dummy guildsettings object is created on initialization of a guild.

And that is about it for now. Will see if I get more time to code this weekend. But only time will show. All changes have been added to the gitlab page.

3 Likes

December 31st - The end of devember

So, updates have been scarce. But I have spent many hours in the past week working on omega. Here are some of the things that I have worked on:
  • Two methods for extensions to communicate with omega and discord. Safe mode uses an abstraction layer that prevents access to objects and information that would let the extension “break out” of the guild walls. Essentially the abstraction layer makes sure the extension does not have access to things like the client, or the guild. This however means that I have to implement all functionality inside this abstraction layer.
  • Therefore there wil also be an unsafe mode for extensions. These will be flagged on init, and omega will check if unsafe access is allowed for the specific instance of the bot. If not, the extension will not be loaded.
    In unsafe mode, objects such as messages, channels and guilds will be sent directly to the extension. This is unsafe because an extension with access to these objects can also access the client and subsequently other guilds than the guild instance the extension is meant for. With this mode an extension can implement all functionality and manipulate guild settings directly, which makes it easier to write more complex extensions.

I will keep working on this project in the coming year. When it gets closer to be finished, maybe I’ll make a new thread for it then.

Anyways. Happy new year everybody!

3 Likes