The bots are taking over!!!

Hello there! I know it’s been a while since my last post, and for that, I apologize. But you see, I am a student after all, and things tend to get rather hectic when ever teacher decides they all want to assign projects at the EXACT SAME TIME!!!@!#!!!@!

Now I know in my very first blog post, I did say I was going to try and contribute to VSCode, but my attention has come to shift to something else for now. I recently just found out that Discord has open source code on Github that people can contribute to!

I’m a massive fan of the Discord software, its slowly become my main form of communication when gaming with my friends, or even having a simply chat with em. RIP Skype! It’s ease of use, and fairly simple integration with the games I play, the services I use, all of which make Discord an amazing piece of software to use. You see, I love Discord, so much so that I even went as far as to make my own Discord bot about three months ago! Below will be a code snippet of my index.js file for my bot. I won’t post all the code as I would like to keep this bot private until I’ve actually gotten it to a state I’m proud to showcase, haha.

const Discord = require('discord.js');
const lolBot = new Discord.Client();
const botSettings = require('./botsettings.json');
const fs = require('fs');
lolBot.commands = new Discord.Collection(); // Collection of bot commands
fs.readdir("./commands/", (err, files) => {
if (err) console.error(err);
let commandFiles = files.filter(f => f.split(".").pop() === "js");
if (commandFiles.length <= 0) {
console.log("No command files found");
commandFiles.forEach((f, i) => {
let cmds = require(`./commands/${f}`);
lolBot.commands.set(, cmds);
lolBot.on("ready", async () => {
console.log(`Bot is ready!`);
// Generate bot invite
// Catch errors if any
try {
let link = await lolBot.generateInvite(["ADMINISTRATOR"]);
} catch (error) {
lolBot.on("message", async message => {
if ( return; // Check if message comes from another bot
if ( === "dm") return; // Check if message is through dm
let userCommand = message.content.split(/[ \t\n]+/, 1)[0].toLocaleLowerCase();
let userArgs = message.content.substring(userCommand.length).trim().split(/[ \t\n]+/); // removes the command, keeps the args and splits em
if (!userCommand.startsWith(botSettings.prefix)) return; // Do nothing if the message sent doesn't start with prefix
let cmdToRun = lolBot.commands.get(userCommand.slice(botSettings.prefix.length)); // Remove the prefix from command
if (userArgs[0].match(/-help/)) {
if (cmdToRun) {
let helpContents =;
let messageToSend = `${botSettings.messageBraces}Command name: ${}\nCommand usage: ${helpContents.usage}\nCommand description: ${helpContents.description}${botSettings.messageBraces}`;;
userArgs = userArgs.filter(items => {
return (items !== (undefined || null || ''));
if (cmdToRun), message, userArgs);

view raw
hosted with ❤ by GitHub

(Don’t judge the code!! I wrote it months ago, I was young, I was inexperienced, I was stupid!) So Discord and their framework isn’t something that’s foreign to me. I’ve had a great interest in them and loved working with their software.

What I want to learn

Whenever I take on any project, my end goal is to learn something new, learn something that makes me go ‘Wow, I had no idea that was even a thing.’ I strongly believe that it’s through this approach to life that we grow as individuals. In taking on this project, I wish to learn a great deal about the Discord software as a whole. Now the reason I say this is simply because Discord incorporates quite a number of very useful things in its software. For instance, there is voice communication in Discord. A technology I would love to learn the inner workings of. How they were able to effortlessly connect any number of people together in one channel and have them talk to one another over voice.

Another feature I would love to learn how to properly implement is a chat system, which Discord has already done so well. You see, about two years ago, I managed to create my own chat system using PHP, JavaScript, Ajax and HTML (you can find it here). Now I’m proud of the work I did back then, I really am. But I am more than confident that it can be improved upon. I mean, Discord did it better. So why can’t I?

When working with their Discord.js package to interact with their API and create my bot, I actually learnt quite a great deal about JavaScript. Thing I didn’t know. Like how to make JavaScript objects on the fly, how to use async/await. How APIs ACTUALLY work.

So yea, I really do look forward to working on this project and learning a thing or two.

What I can do for Discord

Quite frankly, I’m not sure yet. I’m really not, haha. But that doesn’t mean there isn’t a thing I can offer them! After lurking through the Discord.js Github issues, its evident that there are things I can try my hand at. Only in trying my best to help them with their issues can I both learn from them, and them from me (I’m a mediocre coder at best, so they won’t learn much, haha).


As you can tell, Discord has a lot to teach me, and I’m confident that in working on their open source project, I can learn a whole lot. As of writing this, there are currently 124 contributors on this project, and I am positive that number will rise!

I’d like to thank you for taking the time to read this far. If you have any questions, please don’t hesitate to leave them in the comments section!

One thought on “The bots are taking over!!!

  1. Pingback: Playing with the big bois – A. Kabia

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s