Project: Colourbot

17th June 2019 ยท Constantinos Psomadakis

Introduction

Colourbot was my first major project, actively developed for over two years. It was a Discord bot that enabled interactions with colours within the chat. I noticed that many users were screenshotting colours, sharing hex and RGB codes, and discussing palettes without the ability to visualise them. This is where Colourbot came in. By the time it peaked, Colourbot had been added to over 5,000 servers with a total of 500,000 members.

How Colourbot Was Built

Colourbot was written in Python using the Discord.py library, with a MySQL database on the backend to store user and server data. The website was built using PHP, HTML, CSS, and JavaScript.

Building a Seamless Licensing System

I always wanted to monetise Colourbot, so I decided to build my own licensing system using PayPal's API. The system worked as follows:

This system worked incredibly effectively and provided an excellent learning experience in handling financial transactions, security, and database management.

The bot would send a message informing the user that they needed to purchase a license to use certain commands.

You must have a premium account to use this Colourbot command

It would also send a live-updating message to the user when they had successfully activated a license.

The bot showing a user that their account has been activated as a premium account successfully

Minimising bot downtime

The bot grew in popularilty quite quickly towards the end of 2020 even ranking top 10 on some bot websites. This put immense strain on the VPS it was hosted on and since I was on a very tight budget I had to come up with solutions that did not involve upgrading the VPS.

Colourbot mass ping command showing different server response times

This is where I began to learn about sharding. In essence, sharding is the process of splitting up a bot into multiple instances that can run on different servers. This allowed me to distribute the load across multiple servers and keep the bot online even when certain zones were under particular strain. Having to handle database synchronisation and message passing between shards was very challenging - especially for a 17 year old with their A-levels coming up!

Examples of Colourbot in Action