Inspiration 💭

xkcd comics.

They are humorous, comedic, witty, and somehow, Randall Munroe (creator of xkcd, who is also a former NASA programmer and author of 3 amazing books) wraps these comics up in a wonderful package of science, technology, and mathematics with relatable stick figures that seem to be more than simple lines and circles.

Statistics have shown that 98% of MLHers have Discord installed (this is not factual, this is made up to exaggerate the usefulness of my hack but pretty please pretend that it's real), and most of them spend their time chatting around with others or pulling their hair whilst staring at their favourite IDE. While I can't integrate the geniosity of xkcd comics into VS Code or Atom or Sublime Text or butterflies, I can always pull up a couple of Javascript files and work my way around Discord bots.

What it does 🤔

Introducing xkcd! xkcd, the bot, not to be confused with xkcd, the comics, is a xkcd-themed Discord bot whose sole purpose is to retrieve and send xkcd comics of your choosing.

Just kidding, xkcd (the bot) features plenty of other commands, such as help, invite, statistics, "what", eval, reload, flip, and ping commands. What's more, other than just typing in a number to view a xkcd comic of your choice, you can let the bot do the work for you by letting it choose a random comic, or by letting it show you the latest xkcd comic.

How I built it 🛠️

xkcd (again, the bot) was built using Javascript, Node.js, Discord.js, and the xkcd API.

The bot is also hosted 24/7, all thanks to Linode. Its marketplace MEAN stack, coupled with its easy-to-use Debian 9 virtual server blew me away with the accessibility and technicality of Linode. By hosting xkcd on a Linode server, I was able to do other things with my terminal, letting Linode take care of my bot instead of letting my terminal get clogged up with self-hosting console logs.

With a couple of creaks and tweaks here and there, accompanied by my unhealthy obsession for the simplicity yet complexity of Discord bots, you've got the xkcd bot.

Challenges I ran into 😔

I tried to implement per-server settings and per-user settings with the use of databases like Firebase and MongoDB, but I wasn't able to properly implement them.

Accomplishments that I'm proud of 😌

I'm a big fan of xkcd comics as there always seems to be a relevant comic for each situation (but I mean, with 2487 comics and counting, that's expected), so combining the simplicity of the Discord API with the xkcd API is an accomplishment that I can say I'm proud of.

What I learned 📚

This Discord bot was the first time that I've used the 'discord-reply' NPM package. It's extremely handy when getting the user to notice the message from the bot.

What's next for xkcd 📈

There's quite a bit of things that I was planning to do for this Discord bot, but sadly, I wasn't able to implement them properly.

Possible future features include:

  • Per-server settings, such as custom prefixes using Firebase or MongoDB
  • Per-user settings, as there are people who can get annoyed with the bot's line replies
  • A custom website for the bot

Built With

Share this project:

Updates

Submission history