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)