Introduction PlayMakers provides gaming studios with a white-labeled community platform where players can create and contribute in-game assets that can be directly integrated into the game. At the heart of this integration is the Makers Hub , a space for users to share content, get feedback, and connect with the community. And to make engagement even easier, we’ve built a Discord Bot that brings the Makers Hub directly into a studio’s Discord server.
Since Discord is already a familiar hub for gamers, we’re simplifying the experience by allowing players to see all the latest submissions in a dedicated channel, right from the comfort of their preferred platform. This means that game studios can use the bot to fetch and display new submissions in real-time on Discord.
Objectives of this Guide This application note will guide you through the process of:
1. Developing your own Discord bot : Learn the foundational steps for building a custom bot that can respond to user interactions and fetch data from external APIs.
2. Fetching and displaying data in Discord : Discover how to use API requests to retrieve and display content in a Discord channel, allowing for real-time engagement.
3. Applying the PlayMakers Bot as a use case : Use Playmakers’ bot as a practical example of automating in-game asset sharing for a gaming community.
With these steps, you’ll understand how to set up and configure your own bot to pull data from APIs and showcase that information in Discord, enhancing user interaction and keeping the community updated.
Creating Your Discord Bot To set up your Discord bot, you'll need to create a new bot application in the Discord Developer Portal and set the bot's permissions. Below are all the steps you need, from registering the bot to running it with the code setup.
Step 1: Create a Bot on the Discord Developer Portal 1. Go to the Discord Developer Portal and log in.
2. Click on New Application in the top right corner
3. Give your bot a name, and click Create .
4. In the left menu, click on Bot and select Add Bot . Confirm the action to turn your application into a bot.
5. Set an avatar and username for the bot if desired, then configure the bot permissions to match its intended actions.
6. Scroll down to OAuth2 > URL Generator , check the bot option, and select the necessary permissions for your bot. The permissions you’ll need include:
Read Messages and Send Messages to allow the bot to read and post content.
Manage Messages to moderate the messages. Add Reactions to respond to content with emojis. View Channels and Read Message History to fetch channel content. Manage Threads to organize posts and responses in the forum channel.
7. Copy the Bot Token and save it securely—you'll need it for authentication.
Step 2: Add the Bot to Your Server 1. In the OAuth2 > URL Generator section, select bot
and applications.commands
.
2. Under OAuth2 URL Generator , select the bot permissions, and copy the generated link. (the URL is in the format: https://discord.com/oauth2/authorize?client_id=...&permissions=....&integration_type=0&scope=bot)
3. Paste this link into your browser and select the server you want to invite the bot to.
4. Authorize the bot to join your server.
Step 3: Setting up your dev environment To start building your bot, you’ll first need to set up a development environment and install the necessary Discord packages. For this application, we’ll be using Node.js as our programming language
1. Install Discord.js & Initialize a New Client
Install the discord.js
package, which will allow your bot to interact with Discord’s API.
npm install discord.js
After importing the required classes from the discord.js library, you need to create a new client instance with specific intents and partials . These define the bot’s permissions and specify which data types to handle, ensuring that your bot can receive messages, reactions, and interact with members in the server.
const { Client, GatewayIntentBits, Partials } = require ( 'discord.js' );
// Initialize a new client
const client = new Client({
intents : [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessageReactions,
],
partials : [Partials.Message, Partials.Channel]
});
2. Confirm the Bot is Running & login to Discord
Add a simple message to confirm that your bot has connected and is online. When the bot logs into Discord, it will print the bot’s username to the console, indicating that it’s ready to start working.
// Print a message when the bot is online
client.once( 'ready' , () => {
console .log( `Logged in as ${client.user.tag} !` );
});
Finally, use your bot token (saved from the Discord Developer Portal) to log in. This token uniquely identifies your bot and gives it access to your server.
// Log in to Discord with your bot's token
client.login( 'YOUR_BOT_TOKEN' );
3. Listening to User Interactions
With your bot now connected, you can begin adding event listeners to track various user interactions, such as message creation and reactions. We’ll dive into these in the next section, covering how to make your bot responsive to user inputs.
How It Works: Fetching Data Through a GET Request The bot will retrieve and display data by making GET requests to a specified API, which allows it to pull information directly into Discord.
Generally, here’s how the data-fetching process works:
1. Set Up API Request : Configure the bot to send a GET request to an API endpoint. This request should specify parameters, depending on the API request, such as dates, or filters that narrow down the results you want displayed in Discord.
2. Receive and Process the Response : After making the request, the bot receives a response containing the data in JSON format. This data can then be parsed and organized, ready to display relevant details like titles, descriptions, images, or timestamps.
3. Display Data in Discord : Format the data in a user-friendly way and post it in a designated Discord channel, so users can view and interact with the content instantly.
PlayMakers Bot Use Case The PlayMakers bot is designed to retrieve new submissions from the Makers Hub —a community-driven space for in-game asset sharing—and display these submissions directly within Discord. Here’s an example of how to implement the GET request in Node JS for this purpose:
import axios from 'axios' ;
const response = await axios.get( 'https://api.playmakers.co/submissions' , {
params : {
projectId : projectId, // ID of the project in the Makers Hub
state : 'submitted' ,
startDate : startDate, // Fetch only submissions added after the last retrieved date
limit : 10 ,
sortOrder : 'asc'
}
});
project ID: The ID of the specific game linked to the Makers HUB. start Date: In order to filter only newly added posts, we will filter to get only submissions after the start Date, by default start Date is the beginning of the year, so that we can get all the submissions! Save Back the start Date: After getting each new submission, we will save its creation Date as the new start Date. Limit:10 : Since we have rate limits on the Discord side, we’re limiting each API request to get only the first 10 submissions.
To know more about our filters, and sorting parameters you can visit our documentation page
Creating a Forum Channel for Real-Time Submissions To keep your community updated and engaged directly on Discord, you can create a forum channel where submissions appear as individual threads. Each thread will automatically include details like the submission’s title, description, creator's information, thumbnail, and a link for more details. This approach allows players to interact with the submissions by voting, commenting, and participating in discussions without needing to switch platforms.
Here’s how you can set up a forum channel and configure its permissions:
this .channelName = await guild.channels.create({
name : "channelName" ,
type : 15 , // Forum Channel type
reason : "Automatically created makers-hub forum channel for bot operations" ,
topic : "This is the page of Makers Hub where you can see new content from other players, participate in discussions, and engage with the community." ,
defaultReactionEmoji : {
emoji : "👍"
},
rateLimitPerUser : 10 ,
permissionOverwrites : [
{
id : guild.roles.everyone.id,
deny : [ "SendMessages" ],
allow : [ "ViewChannel" , "ReadMessageHistory" , "AddReactions" ]
},
{
id : botRole.id,
allow : [ "SendMessages" , "AddReactions" , "ManageMessages" ]
}
]
});
Channel Type: The forum channel type is 15. Default Reaction Emoji: You can add your own Default preferred Emoji Permissions: Only the PlayMakers Role is allowed to add messages and reactions, all other users have read only settings.
Note: In the example above, botRole
is the variable storing the bot’s role in the server, allowing it to manage submissions within the forum channel.
This way, every new submission gets shared in real-time, keeping the community up-to-date and engaged without needing to switch platforms.
Automating Submission Posts in Discord Automating submission updates in Discord ensures users stay engaged with the latest contributions from the Makers Hub . The bot continuously polls the PlayMakers API to fetch new submissions at regular intervals (e.g., every 10 seconds). This is achieved through the following logic:
async pollSubmissions ( ) {
while ( true ) {
await this .fetchAndPostSubmissions();
// Pause before the next polling cycle
await new Promise ( resolve => setTimeout (resolve, this .pollingInterval));
}
}
How It Works:
1. Polling Interval: The bot uses a continuous loop to poll the API for new submissions at a defined interval. This ensures that any newly added content is fetched promptly.
2.. GET Request: Submissions are retrieved using the PlayMakers API, filtering only new content since the last update.
3. Dynamic Posting: When a new submission is detected, the bot automatically formats and posts it in the designated Makers Hub channel, keeping the community informed and engaged.
Each post contains the following details:
Title and Description : A quick summary of the submission fetched from the API. Creator’s Name & avatar : Acknowledging the player behind the asset. Submission Thumbnail: The thumbnail to show on Discord. Link to the Makers Hub : To provide easy access for users who want more details.
Forum Channel Setup for Organized Submissions Using a forum channel in Discord is ideal for structured, easy-to-navigate content. Each new submission appears as a unique thread with tags based on the type of contribution schema (like "Avatar Icons," "In-Game Sound Effects," or "Logo"). This way, users can filter submissions by category and engage directly within each thread, creating a centralized hub for feedback and voting.
By creating this setup, your community members can enjoy seamless access to new submissions, all without leaving Discord.
Example of a Discord Post:
Gallery View of one of our client’s Channel Example of a thread (submission fetched through api)
What’s Next? While viewing submissions is essential, true community interaction means allowing users to engage directly from Discord . But to make this possible, actions like voting and commenting need to be synchronized with the Makers Hub on the PlayMakers API.
To handle this level of interactivity, we require authorization tokens to ensure actions are performed securely on behalf of each user. Stay tuned for Part 2 of this application note, where we’ll dive into impersonation and show how users can upvote, downvote, and comment right from Discord, with all actions immediately saved on the PlayMakers API.
In the next section, we’ll cover how to authenticate users and process actions like a real community member!
To learn more, you can check our **PlayMakers Documentation .**