How to Build a Roblox Friend Discord Bot With FriendPath
/friendpath user1 user2 with the degrees of separation between two Roblox accounts, in under 100 lines of code. We'll use discord.js v14 (the canonical Node.js Discord library) plus the FriendPath API. Working source code is included — you can copy-paste and have a running bot in 15 minutes.
/friendpath user1 user2 with the degrees of separation between two Roblox accounts. Uses discord.js v14 + the FriendPath Scan API (requires an API key from arbastro Suite — 50 free calls/day). Full working source code below — copy-paste, add your Discord token + FriendPath key, and you have a running bot in 15 minutes.What you'll need
- Node.js 18 or higher (node.js downloads)
- A Discord account and a server you can add bots to
- An arbastro Suite subscription with a FriendPath API key (50 free Scan calls/day included, $0.005/call beyond) — see how to get a key
- ~15 minutes
Step 0: Get your FriendPath API key
The FriendPath Scan API requires authentication. If you don't already have a key:
- Sign up at arbastro.com/signup
- Subscribe to arbastro Suite (30-day free trial)
- Go to arbastro.com/account/api-keys → Create key
- Copy the
ak_live_...key — you only see it once, so store it somewhere safe
Step 1: Create the Discord bot application
- Go to the Discord Developer Portal
- Click "New Application", name it something like "FriendPath Bot"
- In the left sidebar, go to "Bot" → "Reset Token" → copy the token (you'll only see it once)
- Under "Bot" → "Privileged Gateway Intents" — leave them all off, we don't need any
- Under "OAuth2" → "URL Generator", check
botandapplications.commandsscopes, then under permissions checkSend MessagesandUse Slash Commands - Copy the generated URL, paste it into your browser, and add the bot to your server
Step 2: Set up the project
mkdir friendpath-bot
cd friendpath-bot
npm init -y
npm install discord.js dotenv
Create a .env file with your Discord token and application ID (the app ID is on the application's main page on the Developer Portal):
DISCORD_TOKEN=your_bot_token_here
APPLICATION_ID=your_application_id_here
FRIENDPATH_KEY=ak_live_YOUR_FRIENDPATH_API_KEY
Step 3: Register the slash command
Create register.js:
require('dotenv').config();
const { REST, Routes, SlashCommandBuilder } = require('discord.js');
const command = new SlashCommandBuilder()
.setName('friendpath')
.setDescription('Find the degrees of separation between two Roblox players')
.addStringOption(o => o.setName('from').setDescription('First Roblox username').setRequired(true))
.addStringOption(o => o.setName('to').setDescription('Second Roblox username').setRequired(true));
const rest = new REST({ version: '10' }).setToken(process.env.DISCORD_TOKEN);
(async () => {
await rest.put(
Routes.applicationCommands(process.env.APPLICATION_ID),
{ body: [command.toJSON()] }
);
console.log('Slash command registered.');
})();
Run it once: node register.js. After a few seconds you'll see the /friendpath command in your Discord server.
Step 4: The actual bot
Create bot.js:
require('dotenv').config();
const { Client, GatewayIntentBits, EmbedBuilder } = require('discord.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}`);
});
client.on('interactionCreate', async (interaction) => {
if (!interaction.isChatInputCommand()) return;
if (interaction.commandName !== 'friendpath') return;
const fromUser = interaction.options.getString('from');
const toUser = interaction.options.getString('to');
await interaction.deferReply(); // friendpath can take 30-60s
try {
const url = `https://arbastro.com/api/v1/friendpath/path?from=${encodeURIComponent(fromUser)}&to=${encodeURIComponent(toUser)}`;
const resp = await fetch(url, {
headers: { Authorization: `Bearer ${process.env.FRIENDPATH_KEY}` },
});
const data = await resp.json();
if (!data.result) {
await interaction.editReply(`No path found between **${fromUser}** and **${toUser}**. ${data.reason || ''}`);
return;
}
const path = data.result.path.map(u => u.name).join(' → ');
const embed = new EmbedBuilder()
.setTitle(`${fromUser} ↔ ${toUser}`)
.setDescription(`**${data.result.degrees} degrees of separation**\n\n\`${path}\``)
.setFooter({ text: `Searched ${data.result.visited.toLocaleString()} accounts · friendpath.arbastro.com` })
.setColor(0xC4956A);
await interaction.editReply({ embeds: [embed] });
} catch (err) {
console.error(err);
await interaction.editReply(`Error: ${err.message}`);
}
});
client.login(process.env.DISCORD_TOKEN);
Run it: node bot.js. Type /friendpath builderman david.baszucki in your Discord server. You'll get an embed back with the path.
Step 5: Free hosting options
Running node bot.js works while your laptop is on, but you'll want to deploy somewhere 24/7. Options:
- Oracle Cloud Always Free — 4 ARM cores / 24 GB RAM, free forever. Most reliable free tier in 2026. (We host FriendPath itself on Oracle Always Free.)
- Fly.io — requires a credit card to verify, but offers a free hobby tier sufficient for one small bot
- Railway — $5 free monthly credit, more than enough for a Discord bot
- A spare Raspberry Pi at home running 24/7
Rate limits to be aware of
The FriendPath public API endpoint is rate-limited per-IP. For a Discord bot serving one community of friends, this is fine. If your bot starts serving multiple busy servers, you'll want to:
- Sign up for arbastro Suite — gives you 50 free FriendPath Scan API calls per day plus $0.005/call beyond that
- Or cache common results in your bot for an hour or so — most "what's my path to KreekCraft" answers don't change minute-to-minute
Ideas for v2
Once the basic bot works, easy extensions:
- Leaderboard command —
/leaderboard target:david.baszuckiranks your server's members by who's closest - Random famous target —
/random-famouspicks a random Roblox celebrity and finds your path to them (use the FriendPath famous-users endpoint) - Daily challenge — schedule a daily message in the server with a random "find your path to X" challenge
- Mutual friends — show the overlap between two users' friend lists
What this is good for
Friend-path bots are great for content-creator servers, Roblox community Discords, friend groups that play together, and anyone running a "small world" challenge. The FriendPath API exposes everything the main website does, so anything you can do on friendpath.arbastro.com you can wrap in a slash command.
Full reference
Source code for this tutorial: github.com/arbastro/friendpath/examples (planned). Full API documentation: friendpath.arbastro.com/docs. The underlying algorithm explanation: How FriendPath Works: Bidirectional BFS Explained.
Read the FriendPath API docs
All endpoints, parameters, and live request runners.
Open the API docs →Quick FAQ
What is FriendPath?
FriendPath is a free web tool that finds the shortest chain of friends between any two Roblox accounts using bidirectional breadth-first search over Roblox's public friends API. Runs in your browser, no install, no Roblox login required.
What does "degrees of separation" mean on Roblox?
It's the number of friend links between two accounts. If you're friends with someone who's friends with David Baszucki, you are 2 degrees of separation from David Baszucki. Most active Roblox players are within 3–5 hops of any famous account.
Is FriendPath free?
Yes. The web tool at friendpath.arbastro.com is 100% free, ad-supported. The public API offers 50 free calls per day with paid tiers beyond. See the API docs for details.
Does FriendPath work with banned or terminated accounts?
Yes — Roblox's friends API still returns friend lists for banned/terminated accounts, so FriendPath can traverse through them. The path is computed on the public friend graph, not on a player's active session.