Build your Discord bot to build your Extra Life commands (PART 2) - Extra Life JSON Code Discussion & Sharing - Extra Life Community Hub Jump to content
Patricio_tv

Build your Discord bot to build your Extra Life commands (PART 2)

Recommended Posts

Hello and welcome again. We will continue to build our custom bot. We saw how to start building the bot with Discord API on first part of this tutorial, we’re going to install node.js before coding your bot.

 

The first part of this tutorial is here: 

 

 

PART 2

First, what’s node.js?. 

 

Simple and quick explanation: The node.js run-time environment includes all you need to execute java programs written in Java Script. Our bot will be written in JS, Discord and web applications are built with JS too. 

 

Node.js is open source, you can work with it on Linux, Mac or Windows OS. It’s a standard. Node.js’ package ecosystem, npm, is the largest ecosystem of open source libraries in the world. We will use npm to download the Extra Life (to get Extra Life info) and Discord.js (to work with Discord) packages. If you get experience you can get more packages for other cool stuff.

 

Let’s start.

 

  • First step Install Node.js in your computer. I won't explain how to install because depends of each operating system but the process is simple like installing any other software: https://nodejs.org/en/download/   

 

I’m demonstrating this example on Window System. It’s similar on Linux and Mac.

 

  • Create a folder for your Discord bot, mine is “Discordbot”

 

Long version explanation (shorter will added later):

 

  • Open a command prompt on Windows. Run-> type cmd or start-> Windows System->Command prompt
  • Go to your bot folder and run the command “npm init -y” to initialize your Project. This will create a package.json file. No worries, this is like a configuration file to read dependencies, scripts, descriptions, etc.

 

image.png.dad9ec0dc07573e75834ba9bb7ae7e1a.png

 

image.png.1d375296d67dde165c50b3fc04c97622.png

 

Let’s continue by installing the Discord.js library. This library will allow you to interact with Discord API. Remember you built your bot with the Discord API on part 1.

 

  • Run the command “npm install --save discord.js”. You will see the following output.

 

image.png.de731fe493cae49e6dee3cc1b4c60e06.png

 

No worries for the warnings.

 

Now you have the discord.js library on your computer. Let’s move by installing the Extra Life library to interact with the Extra Life API.

 

  • Run the command “npm i extra-life-api”. The output is the following.

 

image.png.c2a0d924b2f07a6496b1b1b153b7da5f.png

 

You have the Discord API on your computer too. Let’s do a brief check list.

 

  • Bot application created on Discord portal (Done)
  • Project initiated (Done)
  • Node.js installed (Done)
  • Discord.js library installed (Done)
  • Extra Life library installed (Done)

 

Alright You got your application bot created and the environment to start coding your bot is ready.

 

Next chapter I will explain how to start to login and run your bot. It will read your Extra Life commands. If you enjoy this, please share!

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...