Discord Bot Written In Node.js
Jan 2019 - Ongoing
- 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
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.
Gallery and Usage Examples
See how the bot is used in the server, including reddit API functions, utility methods, and auto moderation.
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.
I used axios to accomplish API calls. There are good utility libraries for formatting Discord messages and embeds such as discord-embed-maker.
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?
Converting jQuery Blog Post Component To Vanilla JS
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 […]