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

How Starship will change the world

By Dhravya Shah and Sushant Pulipati We all have dreamt of seeing humans on Mars one day. Well, there is one man who will surely get us there. Elon musk.  Elon Musk                         What would you do if you are a millionaire and a vision to change the world?  Of course, you would make a space company with only 1 dream - GET TO MARS .  This is how Starship will change humanity - FOREVE R Starship is a rocket, designed by space company SpaceX. If it becomes successful, it will be by far the most efficient rocket ever designed. Why? Well,  Imagine if you have a paper aeroplane, you throw it once, and then you have to throw it in the dustbin, Waste of resources, RIGHT? You use your energy, time and paper to make an aeroplane, just to throw it once? That's where reusability comes in.  Normally, rockets are flown once and then thrown away in the ocean. All space companies do this.  EXCEPT for  SpaceX.  SpaceX has been reusing the first stage of their rockets (Falcon 9 and Falcon

Nokia - Connecting..... Earth to Moon ?

Nokia has always been nostalgic for the general population, but, after it got defeated by the iPhone in 2007, it has been almost dead, Until now. Nokia is starting a revolution and going to the moon to establish a strong 4g network to boost up the speed and communications between the astronauts   About the mission Nokia has been given a second life by Nasa - in a recent $14.1m contract, awarded to Nokia’s US subsidiary, which is part of Nasa’s Artemis programme which aims to send the first woman, and next man, to the moon by 2024. OK, let's talk about the Artemis mission now.   NASA plans to send the next man and first woman to the lunar surface . The last time NASA sent humans to the Moon was in 1972, during the Apollo lunar mission. And I am very happy to be a p art of this space era.   The Finnish equipment manufacturer said it was selected by Nasa to deploy an “ultra-compact, low-power, space-hardened” wireless 4G network on the lunar surface, as part of the US space agenc