Over the past few weeks, I’ve been working on coding a Discord Bot with both fun commands, and moderation commands. As I’m playing around with the Discord.js library, I learned a ton of neat things about working with it.
Here it is, in case you want to see it.
I wanted to get my bot to get Hypixel Skyblock Bazaar data. However, accessing the Hypixel API can be quite obscure and confusing if you’ve never done it before. So, to save you the trouble, I’ll share with you how my bot pulls bazaar data from the Hypixel API.
Note: We’ll be using JavaScript for this, as we are using Discord.js.
Installing Dependencies
I’m going to assume you’re using using npm, and that you’ve already set up your project file using npm.
To fetch things from a website, we’ll be using the node-fetch package.
Go ahead and install node-fetch. Navigate to your project folder and
npm install node-fetch. You’ll know that it installed correctly when it appears as a dependency in your package.json file.
Next, you’ll want to make sure that you actually use node-fetch in your code:
const fetch = require(‘node-fetch’);