Skip to content
Back to blog
DevelopersGuide

How to make your own Join4Join bot and host it for free

Run your own Join4Join bot: start from the open-source example bot or the public API, host it for free on bot-hosting.net, or let Join4Join run it for you as a community bot.

Published Updated 6 min read

A Join4Join bot brings the whole platform into Discord: your community can discover servers, earn coins, claim daily rewards and promote their own server with slash commands, without opening the website. And it pays you back: every user created through your API key is affiliated to you, so you earn 0.1 coins every time one of them joins a server.

There are three ways to get your own bot, from “I write code” to “I just want it running”:

  1. Fork the open-source example bot and host it yourself (free on bot-hosting.net).
  2. Build your own bot from scratch with the public API.
  3. Use a community bot: give Join4Join your bot token and we run it for you.

Step 1: Get your API key

Everything starts on the Developer page of your dashboard. Generate your API key and keep it secret: anyone who has it can make requests in your name. If it leaks, regenerate it from the same page.

The full API reference is on the documentation page.

Step 2: Create a Discord bot application

You need a bot account on Discord’s side (skip this step if you only want to test the API):

  1. Open the Discord Developer Portal and create a New Application.
  2. In the Bot tab, reset and copy the token. This is your bot’s password: never share it publicly.
  3. In OAuth2, use the URL generator with the bot and applications.commands scopes. The generated link is your bot invite link.

Option A: the open-source example bot

The fastest path is the official example bot on GitHub. It is a complete, ready-to-run bot:

  • Node.js 18+ and discord.js 14, with a tidy structure that is easy to extend.
  • Slash commands for everything: /farm (servers to join with Join and Claim buttons), /daily, /balance, /check (can I leave this server yet?), /info, /buy (start a campaign for a server), /pay (send coins to a friend), /invite, /help and /stats (your developer earnings).
  • English, French and Turkish, picked automatically from each user’s Discord language.

Install and configure it

Clone the repository, install the dependencies and create your configuration file:

git clone https://github.com/join4join/nodejs-join4join-example.git
cd nodejs-join4join-example
npm install
cp .env.example .env

Open .env and fill in the values:

TOKEN=your_discord_bot_token
API_KEY=your_join4join_api_key
BOT_INVITE_LINK=your_bot_invite_link

# Optional
GUILD_ID=
ADMIN=
OWNER=
  • TOKEN is the bot token from the Developer Portal.
  • API_KEY is your Join4Join key: every user of your bot gets affiliated to it.
  • BOT_INVITE_LINK is the link people use to add your bot to their servers.
  • GUILD_ID (optional) registers the slash commands instantly on one test server. Leave it empty in production to register them globally.
  • ADMIN and OWNER (optional) are comma-separated Discord IDs allowed to run the restricted commands, like /stats.

Then start the bot:

npm start

That is it: invite the bot to your server with your invite link and type /help.

Option B: build your own bot with the API

Prefer another language or library, or want to integrate Join4Join into an existing bot? Use the public API directly. It is documented on the documentation page and works the same way from any language:

  • 10 endpoints under /api/v1, all POST requests with a JSON body.
  • Authentication with your API key in the Authorization header.
  • A rate limit of 50 requests per minute per key.

The endpoints cover users (user/create, user/get), farming (join4join/farm, join4join/check, join4join/check/all, join4join/daily), promotion (join4join/info, join4join/buy), transfers (join4join/pay) and your own numbers (developer/stats).

Here is how to fetch a user and their balance in JavaScript:

const res = await fetch('https://join4join.xyz/api/v1/user/get', {
	method: 'POST',
	headers: {
		Authorization: process.env.API_KEY,
		'Content-Type': 'application/json'
	},
	body: JSON.stringify({ user_id: '123456789012345678' })
});

const { success, data, message } = await res.json();
if (success) console.log(`${data.id} has ${data.coins} coins`);
else console.error(message);

Every response has a success boolean, and a message explaining the problem when it is false. Users who do not have a Join4Join account yet are created and affiliated to you the first time your key sends them.

Host your bot for free on bot-hosting.net

A bot has to run 24/7, and your own computer is not a great place for that. bot-hosting.net offers free hosting for Discord bots:

  1. Log in with your Discord account.
  2. Create a Node.js server.
  3. Upload the bot files (or deploy them from GitHub: the example bot README has a one-click deploy button).
  4. Add your .env values, then start the server.

Check the logs in the panel: you should see your bot come online within a few seconds.

Option C: no code at all, use a community bot

If you do not want to code or host anything, open the Developer page and add your bot token as a community bot. Join4Join runs the bot for you, with all the commands, on our servers.

You still get the rewards:

  • 5 coins per day to claim while your bot is online.
  • The referral share on the users of your bot: 0.1 coins each time one of them joins a server.

A bot token gives full control of the bot, so only add it on the official Developer page, and never paste it anywhere else. You can reset it at any time in the Discord Developer Portal to take back control.

What you earn as a developer

Whatever option you pick, the users your bot brings are affiliated to you:

  • 0.1 coins every time one of them joins a server (they earn 0.75 coins for it, you get your share on top).
  • Weekly prizes if you climb the referrer leaderboard.

Follow your numbers with the /stats command of the example bot, the developer/stats endpoint, or the referrals page.

FAQ

Do I need to know how to code?

No. A community bot runs without a single line of code. The example bot only needs a few values in a .env file.

Is it really free?

Yes. The API is free, the example bot is open source, and bot-hosting.net offers free hosting.

Can I change the example bot?

Of course: fork it, rename it, add commands, translate it. It is built to be extended.

What happens if I hit the rate limit?

Requests above 50 per minute get an error message instead of data. Cache what you can and retry a bit later.

Keep reading