Discord Bot Written In Node.js

Jan 2019 - Ongoing
Goals
  • Make an in-house bot that can manage a growing Discord server
  • Account for edge cases and vulnerabilities coming from user input
  • Hosting the bot and keeping it online during all hours

Project Overview

Berrybot is a side project that I work on for fun. I’ve worked on it for months now, adding features as I went along. Eventually, users in the server requested certain features that became implemented. There’s really no limit to what Discord bots can accomplish, making it an ongoing process.

Process

Getting started with Discord bots is fairly simple. You need to hook up the discord API that’s available for your preferred language, then setup a simple starter to get it going. I found a starter script online and modified it to my needs. I started with simple commands since I was just starting to learn. Eventually I hooked up APIs and utilized Node’s power to make several types of API calls.

As data grew, I outsourced data into its own ‘component’ and did the same to group similar sets of commands. After the structure was set up, scaling up was easy since I could add commands and their logic to separate files. Moving forward, keeping code split up keeps the app maintainable without tangling logic.

Technologies Used

Node.js
The only technology required here was Node.js/Javascript. I chose Node because I was familiar with it already, and wanted to further improve my JavaScript skills.

JavaScript libraries
I used axios to accomplish API calls. There are good utility libraries for formatting Discord messages and embeds such as discord-embed-maker.

APIs
Most of the features on this bot use the Reddit API, with a wrapper library called snoowrap. Other than that, there’s some basic APIs for grabbing quotes and other one-off functions.

Want to check out some code demos?

Check out code samples written in JavaScript, React, Node, and more

Demo 1
Converting jQuery Blog Post Component To Vanilla JS

I have a simple blog component that is written in jQuery. I would like to convert it to plain JavaScript as part of my effort to completely remove jQuery from my portfolio website. Here’s what the code does in order. init() on .header-info click, call the toggle method. Get the initial textbox height and store […]

Demo 2
Converting jQuery Navbar Code to Vanilla JavaScript

I am on a journey to completely replace jQuery on my portfolio site. The first step is updating the 10 or so JavaScript files that still rely on it. Why not start with one of the easier ones, the navbar? As you can see, the code is pretty straightforward. On init, add event listeners to […]

Demo 3
Defining Reusable Column Extends with SCSS

Quick Note: The atSmall type mixins are just basic media queries. Since these kinds of layouts are common, they also need to be overwritable if I want to change the spacing. Generally, the ‘default’ spacing is defined in the extend/mixins. Example Use Cases To get the layout working, you only need a container class and […]

View all 5 code samples