Skip to main content

Rewriting Spacebot: Part2 - Having FUN with VIEWS VIEWS VIEWS

Rewriting SpaceBot p-2

This is just day 1 and I feel very confident, even though it's been a little difficult. I decided to start with the bot in such a way that I can scale it almost infinitely, so I jotted down 5 things to do for the day: Complete the main file, Set up a good logging system, Decide a file structure for super clean code, Complete the fun cog WITH slash commands, and decide the database schema.

All that, while travelling from Mumbai to Deolali 

Do you think I managed to do it?
I did most of this coding while in the car travelling from Mumbai to Deolali (I'm returning home as I write this blog). 

A good logging system

First, I asked myself: What makes a good logging system?
These are some criteria I put for myself
  • Proper log levels
  • On-point log messages
  • Important logs and spammy logs should be different
  • Full traceback for only the errors that need it
So, after I completed the pretty basic main.py file and got the bot working, I started doing logging. 
I think that works pretty well. Idk if logging can be done asynchronously so i just used the built in `logging` module

I've set it up in such a way that all necessary information is provided for all errors. And for critical errors, the bot completely stops and spam pings me in my DM (security feature haha).

File system

I want my code to be extremely clean and organised, no compromises. I put all code in the src folder (with the env, gitignore, requirements.txt, license, etc. outside). Fun fact, I had to completely change everything about Spacebot 2.0 when I decided to make it open source, because the files werent organised at all.
So this is what I settled on, pretty happy with the result


Also, I didnt want to views to be inside the cog files itself, because it looks extremely ugly that way, so I added a views file (ignore the other utilities more on that soon)

Fun cog

I went on to rewrite every single fun command. Also added this neat button to use the command again (because most people are lazy like me lol). 

VIEWS VIEWS VIEWS

I've added some kind of view/button/interaction to almost every single command that isnt a webhook or isnt too simple. I'm a madman? agreed. 
Every embed looks pretty much like this

And added buttons to a lot of stuff
That's pretty cool isnt it haha

If you want to see me do all this, help me test the bot etc. by joining The Coding Horizon


After doing this. I was bored. Like really really bored. I had all the stuff done (pretty much) and half of the journey was still left (remember, all this was done while i was travelling in the car)
Only slash commands and database schema was left, and it wasnt even 1pm yet
So I went on to create an amazing command corrector system:
I did this using SequenceMatcher from difflib library

Now, for the database

I always move away from databases because of a number of reasons, one of them being 

Bruh, too much work

                        - Dhravya, 2022

 

I started writing down everything that i need to store in the database, which is a MySQL database hosted on my VPS. I went crazy and included everything I could think of.

The blog is getting too big right now and I have to set up a subscription system for it, so I'll continue tomorrow.

So, these are the things I've completed in spacebot rewrite already:

  • Fun cog
  • Database Connection systems
  • Logging
  • Views, a LOT of views
  • Command hinter system
  • Database Schema (IN NEXT BLOG THOUGH)
What did I learn?
  • How to log errors and information efficiently
  • How to organise folders for a great developer experience and clean code
  • Mastered pycord interactions sytem
  • Finding similar "stuff" using difflib
I'm working on an email subscription system for the blog for the 5 people who wanna get notified when i get home :)

Comments

Anonymous said…
noice lol
Sushi said…
GG! Never gonna give up spacebot!!
Anonymous said…
my 7 years old sister could make a better page than this

Popular posts from this blog

Rewriting Spacebot: Part1 - Deciding features and tech stack

Why Rewrite? The answer is very simple: I'm not really happy with the current state of Spacebot. Its growth is slowing down, I'm less motivated to work on the project because of just how basic it is. But this is gonna change now. Deciding the features I don't just want to make Spacebot multipurpose, I wanna make it a *good* multipurpose bot.  That is, every feature that I add to SpaceBot should also add a considerable amount of value to any discord community, which is what I think Spacebot lacked earlier. It has like 60 utility commands but most of them aren't done well. Spacebot has these features currently:  Very bad moderation  Very bad "Fun" commands  Kinda useful Utility commands but most aren't good  Kinda good Music system, I might just keep the music system as it is in the rewrite (with a few visual changes) And then there's button roles, Discord together and stuff. Which isnt really good tbh What I want to include in the rewrite: Moderation, A...

Rewriting Spacebot: Part3 - AUTOMOD, DATABASE GO BRRRRRRRRRRRRRRRRRRRRRRRR

 I'm really proud of this week.     Over the last week I managed to make the Automod,  work.  definitely wasnt as easy as I thought, but it works now. Join me through the thinking process and "Making it work" process in this blog. Maybe follow me on twitter? To be honest, setting up the database and caching was the hardest part. But this useful extension made everything so so so much easier. MUST HAVE Extension ( 1 ) for everyone working with #mysql on @VisualStudio This one allows you to connect to the database and edit, create columns/ rows without any code/minimal code!!! Also lets you backup your database, use pre-written SQL queries, view tables and much more pic.twitter.com/gx7cZZwmrd — Dhravya Shah (@DhravyaShah) February 6, 2022 You can follow me on twitter. I often share my experiences and stuff there  Automod Figuring out database structure Some wise man told me, "Once you make your relational database, you regret the structure for your entire ...

The New Era of Space travel has started, and how you can go to space now (for free)

Ever since spaceflight was a thing, it has been used by governments to assert dominance against other countries, even the moon landing project was done solely for this purpose But this is changing. While government agencies like NASA and ISRO are doing all their great things, they are far more boring to the audience, because they are interested in science-based projects like satellites On the other hand, companies like SpaceX, Rocketlab, Virgin Galactic, and Blue origin have been working on something much bigger-  Space tourism.   And its not just a competition on who makes better and safer rockets for billionaires, its a race to push the boundaries of what humanity can do, which will inevitably (albeit slowly) make space available to the common people. Now lets talk about the rockets. Fun stuff! First, lets clear out the confusion between 'space' and 'orbit'  Space is just everything beyond the boundary of about 80 kms. Its a lack of atmosphere, but not a lack of gravi...