We all love free games. But we all hate remembering to claim them.
Every Thursday, Epic Games drops a free title. Steam randomly makes paid games free for a weekend. If you aren't glued to Reddit, you usually miss it.
Today, we fix that.
Weβll build LootBot, a simple Discord bot that checks for active freebies and posts them to your server.
β The Old Way
Scrape the Epic Store website using Puppeteer:
- Slow
- Heavy
- Gets IP banned
β The New Way
Use Game Deals & Freebies API:
- Free
- Fast
- No scraping headaches
Letβs get coding. πΊ
π§© Step 1: The Setup
1. Create a Discord Bot Token
- Go to the Discord Developer Portal
- Click New Application β name it
LootBot - Open the Bot tab β click Add Bot
- Scroll to Privileged Gateway Intents
- Enable Message Content Intent
- Copy your Bot Token and save it
2. Initialize the Node.js Project
npm init -y
npm install discord.js axios dotenv
π Step 2: Get Your Free API Key
We arenβt scraping websites today. Itβs 2026 β we use APIs.
Weβll use Game Deals & Freebies API from RapidAPI. It aggregates data from Epic Games, Steam, and GamerPower into a clean JSON feed.
- Go to Game Deals & Freebies API on RapidAPI
- Click Subscribe to Test (Basic tier is free)
- Copy your X-RapidAPI-Key
π§ Step 3: The Code
1. Environment Variables
Create a file named .env:
DISCORD_TOKEN=yourdiscordbottoken_here
RAPIDAPI_KEY=yourrapidapikeyhere
2. Bot Logic (index.js)
The bot listens for !loot and replies with currently active free games.
require('dotenv').config();
const { Client, GatewayIntentBits, EmbedBuilder } = require('discord.js');
const axios = require('axios');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent
]
});
async function getFreeGames() {
const options = {
method: 'GET',
url: 'https://game-deals-freebies-api.p.rapidapi.com/epic',
headers: {
'X-RapidAPI-Key': process.env.RAPIDAPI_KEY,
'X-RapidAPI-Host': 'game-deals-freebies-api.p.rapidapi.com'
}
};
try {
const response = await axios.request(options);
return response.data.active;
} catch (error) {
console.error('API Error:', error);
return [];
}
}
client.on('messageCreate', async (message) => {
if (message.author.bot) return;
if (message.content === '!loot') {
await message.channel.send('π Scanning for freebies...');
const games = await getFreeGames();
if (games.length === 0) {
return message.reply('No free games found right now. Check back later!');
}
games.forEach(game => {
const embed = new EmbedBuilder()
.setColor(0x0099FF)
.setTitle(game.title)
.setDescription(game.description)
.setImage(game.image)
.addFields(
{ name: 'Original Price', value: game.originalPrice || 'Free', inline: true },
{ name: 'Status', value: 'π₯ Active Now', inline: true }
)
.setURL(game.storeUrl)
.setFooter({ text: 'Powered by Game Deals & Freebies API' });
message.channel.send({ embeds: [embed] });
});
}
});
client.on('ready', () => {
console.log(`πΊ LootBot is online as ${client.user.tag}!`);
});
client.login(process.env.DISCORD_TOKEN);
βΆοΈ Step 4: Run It
node index.js
Invite the bot to your server (via OAuth2 in the Discord Developer Portal), type:
!loot
And watch the magic happen β¨
π€ Why Use an API Instead of Scraping?
Scraping works β until it doesnβt.
- Speed β APIs respond in milliseconds
- Maintenance β HTML changes break scrapers
- Bandwidth β Clean JSON instead of heavy HTML
- Reliability β No IP bans or CAPTCHAs
π Whatβs Next?
You can expand LootBot to:
- β° Auto-check freebies every Thursday using
node-cron - π° Track discounts via the
/dealsendpoint - π Find Steam beta keys using
/freebies - π’ Auto-ping roles when new games drop
π Resources
Happy coding! πΊ
Top comments (0)