Return to Level1Techs.com

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