Skip to content

Nodejs Join4join Example

by Mister X Node.js Other

Host your own join4join bot using the join4join api. Grow your Discord Server by thousands of members daily using the official join4join bot on Discord.

Nodejs Join4join Example screenshot 1
README.md

Join4Join - Open-Source Discord Bot

A clean, ready-to-fork Join4Join bot built on the official Join4Join API. Run your own bot, grow Discord servers for free - and earn developer rewards every time your users farm.

Every user your bot creates is automatically affiliated to your API key. You earn +0.10 coins each time one of them farms a server, plus +10 coins for every new user who signs up through your affiliate link. Passive income. ๐Ÿš€

Website โ€ข API Docs โ€ข Support

Deploy on Bot-Hosting


HOST THE BOT FOR FREE: bot-hosting.net


โœจ Features

  • 10 slash commands - help, invite, balance, daily, farm, info, check, buy, pay, stats
  • Multi-language ๐Ÿ‡ฌ๐Ÿ‡ง ๐Ÿ‡ซ๐Ÿ‡ท ๐Ÿ‡น๐Ÿ‡ท - every user sees the bot in their own Discord language, automatically
  • Intuitive UX - /pay @user amount and /buy with inline options, no clunky forms
  • Interactive farming - one-click Join buttons, Claim and Refresh
  • Robust - timeouts, deferred replies (no more "This interaction failed"), clean error embeds
  • Easy to fork - tidy structure, commented code, zero boilerplate to add a command

๐Ÿ’ฐ Developer rewards

Running your own Join4Join bot pays you back. Every user your bot creates is automatically affiliated to your API key (their account is linked to you the first time they appear in any API call), and you earn coins from what they do:

Reward When it's paid Amount
Affiliation signup A new user signs up on join4join.xyz through your affiliate link +10 coins
Farm One of your affiliated users farms a server (real account, not an alt) +0.10 coins

๐Ÿ’ก The +10 signup bonus is credited when someone registers on the website via your affiliate link (grab it from your dashboard), so don't hesitate to share it in your bot. The +0.10 per farm is fully automatic for every user your bot creates.

Track your earnings anytime with /stats.

๐Ÿ“ฆ Requirements

๐Ÿš€ Installation

Bash
# 1. Clone the repository
git clone https://github.com/join4join/nodejs-join4join-example.git
cd nodejs-join4join-example

# 2. Install dependencies
npm install

# 3. Configure your bot
cp .env.example .env      # then open .env and fill it in

# 4. Start the bot
npm start

That's it - your Join4Join bot is live! ๐ŸŽ‰

Configuration (.env)

Variable Required Description
TOKEN โœ… Your Discord bot token
API_KEY โœ… Your Join4Join API key (users get affiliated to it)
BOT_INVITE_LINK - The link people use to add your bot to their servers
GUILD_ID - A test server ID - registers commands instantly during dev
ADMIN / OWNER - Comma-separated Discord IDs allowed to run admin/owner-only commands

During development, set GUILD_ID so slash commands appear instantly. In production, leave it empty to register commands globally (can take up to 1h).

๐Ÿงญ Commands

Command What it does
/help List every available command
/invite Get the useful Join4Join links
/balance Show your coin balance and recent transactions
/daily Claim your daily coins every 24h
/farm Get servers to join and earn coins (with Join / Claim buttons)
/info Join4Join info about the current server
/check Check if you can leave a server without losing coins
/buy /buy invite members [language] [filter_alts] - advertise a server
/pay /pay user amount - send coins to a friend
/stats Your developer earnings & affiliation stats (owner-only)

/stats shows your affiliation revenue (you earn 0.10 coins each time one of your users farms). It's restricted to the Discord IDs listed in OWNER in your .env, so leave that empty and it stays private to nobody but you.

๐Ÿ—‚๏ธ Project structure

โ”œโ”€โ”€ index.js               # Entry point: creates the client, loads everything
โ”œโ”€โ”€ config.js              # Reads & validates your .env
โ””โ”€โ”€ src/
    โ”œโ”€โ”€ api/               # Join4Join API layer
    โ”‚   โ”œโ”€โ”€ request.js     # fetch wrapper (auth header, timeout, JSON)
    โ”‚   โ””โ”€โ”€ join4join.js   # typed methods: getUser, farm, buy, pay, daily...
    โ”œโ”€โ”€ commands/          # One file per slash command
    โ”œโ”€โ”€ events/            # ready.js + interactionCreate.js (the router)
    โ”œโ”€โ”€ i18n/              # Translations
    โ”‚   โ”œโ”€โ”€ index.js       # t(locale, key, vars) + locale resolution
    โ”‚   โ””โ”€โ”€ locales/       # en.js ยท fr.js ยท tr.js
    โ”œโ”€โ”€ loaders/           # loadCommands ยท loadEvents ยท deployCommands
    โ””โ”€โ”€ utils/             # embeds.js (branding) ยท logger.js

โž• Add your own command

Create src/commands/ping.js:

JavaScript
const { build } = require("../utils/embeds");

module.exports = {
    name: "ping",
    descriptionKey: "commands.ping", // add this key to src/i18n/locales/*.js
    dmPermission: true,

    async execute(interaction, ctx) {
        const embed = build(ctx, { title: "Ping", description: "๐Ÿ“ Pong!" });
        await interaction.reply({ embeds: [embed] });
    },
};

Add ping: "Check the bot latency." under commands in each locale file, then restart. The command loads and registers itself - no wiring needed.

Each command receives a ctx object:

Field Description
ctx.t Translator bound to the user's language: ctx.t(key)
ctx.api The Join4Join API methods
ctx.config Your resolved configuration
ctx.client The Discord client
ctx.locale The resolved locale (en / fr / tr)

โ˜๏ธ Free hosting

You can host this bot for free on bot-hosting.net.

๐Ÿ†˜ Support

Need help? Join the Join4Join support server.

๐Ÿ“„ License

MIT ยฉ Join4Join