Writing your own JSON code to pull your participant data or your team's data out for use on your stream or other places? Share your code with the rest of the community! Looking for a code snippet to do something specific? Ask for it here.
Extra Life United is a gaming event like no other. Participants compete in a gaming tournament on behalf of their local Children’s Miracle Network Hospital, meet the children they support by being a part of Extra Life and connect with other Extra Lifers from across the globe. The tournament features popular tabletop and video games that everyone enjoys!
Ask your question and have it answered by other Extra Lifers. You can vote on which answer is best so other members can see your question and the best answer. This area functions much like a live FAQ that is constantly updated by the Extra life Community.
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:
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.
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.
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.
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.
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!
Extra Life has grown up last years. Today we got overlays, Extra Life helpers and donations alerts on Streamlabs and Streamelements but what about Discord? nothing that I know. I didn’t find a good way to check my participant or team information directly from my Discord server, I needed to visit the official web site every time I needed to check the info. I started to think a way to get common Extra Life info directly from Discord using simple commands, faster and easy, why? because Extra Life is on Twitch, Twitch is integrated with Discord and some Discord communities are strong and supporting Extra Life, it’s good way to post information about your Extra Life campaign, your donors, your goals, your Extra Life marathon, the Extra Life stream team schedule and more for you members. Possibilities are many.
What did I need to do that? A custom bot and a way to get the information.
I’m going to share this short tutorial to build your custom bot and use the new Extra Life API to build your own commands. This API was released some weeks ago.
- A Discord account
- The Extra Life API: https://www.npmjs.com/package/extra-life-api
Note: I always suggest to use a test environment. There is not risk about security issues because you’re using a Discord API, Extra Life API and you’re setting your bot permissions. You can add and remove your bot anytime. This is not an Extra Life official bot, I'm explaining how you can build one yourself. The Extra Life bot name and logo are friendly examples for this tutorial. Please if you want to use them ask for approval to staff team or team leaders.
The first part of this tutorial is show you how you can build your Discord Application (your bot), you will find different ways to do this on internet, use whatever best suits for you.
You will add your bot to your Discord Server, later you will be able to build your Extra Life commands as your preference.
Here we go:
I'm assuming you already have a Discord account, if not create it please.
Go to Discord Developer Portal and select applications: https://discordapp.com/developers/applications/
Click on new Application
Write a name and create
General info tab: Upload a picture, complete the description (optional) and save the changes.
Go to bot tab and click on add bot. After confirmation your bot will have visibility with Discord.
After bot creation. You will see a confirmation a new options available.
Now your bot has a token, this works like a password so take care of it. You can regenerate it any time in case your security is compromised. This token will allow you to connect your bot with Discord when you start to build your commands.
Go to oauth tab. We’re using a bot application so our scope is “bot” and set your permissions.
on the permissions you set like any other bot (Dyno, Mee6, couchbot, etc). I’m using few here permissions because I don’t want the bot manage channels, roles, kick members or these kind of administration actions. The bot just use commands to get Extra Life information. If you want to give your bot more permissions for administrations purposes is up to you.
The red number are your permissions, it will change each time you add or remove permissions, you can calculate this number on bot tab too.
Copy the link and paste it on your browser. See what happens.
If you did all correctly, you will authorize your new bot to join your Discord server with the permissions you set before. It’s clear, isn't it?
Now choose your Discord server and set authorize. You receive the following confirmation.
Go to your Discord Server and check if the bot is joined. It should be there offline.
Alright your bot is joined and offline. Why offline? because you used the Discord API to build your bot but it still wasn’t developed to listen messages, read commands and reply.
What did you learn here?
Use the Discord API to build your bot.
Understand how permissions work and are set.
Understand how bot invitations work.
Understand how your bot joins on your Discord server.
Next chapter I’m going to explain how you should install Node.js to start coding your bot. You will use your bot token to login on Discord, it will be online and ready to listen for messages.
If you enjoyed this content, please share it!!!
I want to share this useful API that I found on internet. If you have a custom bot and you want to get Extra Life info directly from your Discord server without checking the web site. Install this API and you can create custom commands to get information.
WARNING: I'm assuming you have a basic knowledge about development. 🤯
-You need to install node.js on your PC or server first. Download it here: https://nodejs.org/en/download/
The installation instructions to install the Extra Life API is here: https://www.npmjs.com/package/extra-life-api
If you don't want to read, just go to your bot folder and run this command: " npm i extra-life-api", you should see an output like this:
Ignore the warnings
Once the installation is completed, you are able to create your custom Extra Life commands for your Disord bot. We got just 4 methods for now to get information: getUserInfo, getUserDonations, getTeamInfo, getTeamRoster and getTeamDonations . All the information about how to use them and what information we can get is on the web site.
I will add later how you can build your Extra Life bot or add these functionalities to your current custom bot. I leave you some basic examples what kind of things you can do to start. A big thank you to @Alex Muench for sharing and all the developers who worked on it. If you like this work consider to donate: https://www.extra-life.org/index.cfm?fuseaction=donorDrive.participant&participantID=362008
Let me know if you need help or anything.