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
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 […]

Demo 2
Discord Bot: Reddit API Ask Feature

The Purpose Some Discord bots have a feature where you can “chat” with the bot(i.e: Cleverbot integrations). I decided to take a spin on this concept and utilize the Reddit API to answer common questions. A user from the server asks a question using the b!ask command, then the bot gives a random answer from […]

Demo 3
React.js Modal Using The Hooks API

Modals are a classic piece of application functionality, made even easier with libraries like React. You could go with a library, but you can often make your own with less than 100 lines of code. Using the hooks API, you don’t even need a class based approach. This example is going full functional! Defining The […]

Need something? Let's get in touch