How to create a Discord - ROBLOX Member Counter / Includes Repl.it and API Hosts

Hello, it has come to my attention alot of you guys used campfirehq.net for member counters.
Alot of you liked them so I thought I would show you how to make one for yourself!

To limit webhook logging bots, we are using a discord bot setup.
Before we start, create an account on Repl.it and UptimeRobot.com.

We use UptimeRobot.com to keep it online, the bot would timeout after 5 minutes after no activity otherwise.

My Code

https://replit.com/@tozzleboy/Roblox-MemberCount

//d888888b  .d88b.  d88888D d88888D 
//`~~88~~' .8P  Y8. YP  d8' YP  d8' 
//   88    88    88    d8'     d8'  
//   88    88    88   d8'     d8'   
//   88    `8b  d8'  d8' db  d8' db 
//   YP     `Y88P'  d88888P d88888P 
                                  
                                        

const express = require('express');
const app = express();
const port = 3000;
app.get('/', (req, res) => res.send(`Member Count Page - Nothing to see here.`));

app.listen(port, () => console.log(`Example app listening at http://localhost:${port}`));

//Do not edit things above this line.

//ONLY EDIT THINGS BELOW HERE ------------------------------------
const Discord = require('discord.js');
const client = new Discord.Client();
const groupId = "5627994";
const snekfetch = require("snekfetch");
const ServerId = 'Insert discord server id here.'; //The bot MUST be in your server.
const ChannelId = 'Insert channel id, ensure bot can send in the channel or you get errors!';
let goal = 500 // Set this to your member goal!
//ONLY EDIT THINGS ABOVE HERE ------------------------------------

//Created by Tozzleboy - Discord = Tozzleboy#5173

let rbxapi = `https://groups.roblox.com/v1/groups/${groupId}`; //Do not edit this.
let lastCount = 0
setInterval(function(){ 
      snekfetch.get(rbxapi).then(r => {
      let body = r.body; 
        const guild = client.guilds.cache.get(ServerId);
        const channel = guild.channels.cache.get(ChannelId);
        if(!Number(body.memberCount) === lastCount) {
          channel.send(`We are currently at ${body.memberCount}, ${goal - Number(body.memberCount)} until we reach ${goal}!`)
        }
         });
}, 30000);


client.login(process.env.TOKEN); // To make your bot work, do not edit this. Press the padlock logo on the left bar, and make a value in there called "TOKEN". Insert your bot token in there. DO NOT SHARE THE TOKEN WITH ANYBODY, anybody can access this code online therefore we must put the token in the padlock.

//WRITTEN BY Tozzleboy

Step 1
Create a discord bot.
To do this, go to this website:
https://discord.com/developers/applications

Now press this button.
image

Fill in the information, I use Discord Bot as a name for the tutorial. Name it something unique.

Select this button on the left:
image

Now press:
image

Great! You now have your own discord bot created!

Step 2
Inviting the bot to your server with permissions.

Select this button on the left:
image

Scroll down fill in the checkboxes as shown below:

Copy this link, and then paste it into a new tab and add the bot to your server:

You have succesfully made a discord bot! Now to the code that runs it!

Step 3
Customising the code to work with your group and the bot.
Go to this link and press the fork button:

Now you have the code to run the bot!
It should look simmilar to this.

Edit these 3 variables and set them to the Guild/Dc Server Id, Group Id and the Dc Channel Id.


Once you have done that, press run.

Now go back to the discord developer page and under the bot tab press copy for token.
image

Now go back to the repl, and press the padlock button on the left.
image

Insert the following information but insert the copied token into the part where I said keep it private!
image
Now press run at the top, check if your bot is online in your server, if it isn’t something went wrong, do not DM me if this happens, reply below.

Step 4
Keeping the bot alive.
Now that the bot if up and running, you must setup UptimeRobot.com.

Once you press run, the first time it will take a while as it needs to download the modules, other times should be quicker.

This thing should appear on the right:


Copy the highlighted link and go to a tab with uptime robot open.

Press this button:
image

Change everything to look like this, when you get to the URL part, highlight everthing in that box and press delete, then you can paste your URL in.

Step 5
Test it out!
The bot checks for new members every 10 seconds.

If you have issues contact me below in the replies or on discord!

8 Likes

Discord is not a logging service and this is API abuse. I would strongly advise against using this or similar bots.

4 Likes

This is not exactly API abuse. As Discord has said, this is a grey area for them. They usually won’t take any action as long as you follow the ratelimit headers. But I would still not recommend you to do this.

3 Likes

What do you guys mean by this?

Discord did not say it was a gray area. It seems pretty clean-cut:

Better, more accessible, more powerful tools that are actually intended for logging exist. Just use one of them.

3 Likes

My bot isn’t online- can you help me please?

This is not API abuse because it doesn’t use webhooks! Basically the bot is getting the API abuse here not discord.

I’m not to sure if discord bots spamming is API abuse, but thats saying if I as a user were saying New user every 10 seconds, am I abusing discord, no.

Unless discord bots hook into the discord api to work then I’m wrong.

Are you sure you setup the token part correct, what is shown in the output?

That is indeed how bots work; every website uses an API if it allows external programs to interact with it like that.

1 Like

I am pretty sure I have, here is a screenshot of what is showing:

Did you invite the bot to your server?

Yes, i have, i’ve also done all the steps

image
also you could make it send one message and edit that one instead of sending new ones (for the ones complaining that this is api abuse)

1 Like

It isn’t working, I’ve done everything.

Few problems here.

  1. Abusive against the discord API as @rogchamp said. Could result in termination or deletion of your discord account.
  2. Not worth it for a member counter.

I am sure there is an alternative way of checking this, such as requesting the discord invite and scraping the part that says how many members are in a server. This current method is a lot more intensive for discord than it needs to be.

3 Likes

This is really nice, but for users not familiar with JavaScript and Discord.js, they will not be able to figure out how to change the message.

I’d recommend making a way to do this easily for users whether it be a variable with a replace function or a full-on embed customizer.

Here is a simple replace function I made :slight_smile: :

async function replace (msg, count) {
    const replacements = {
      '%COUNT%': count
    }

    return msg.replace(/%\w+%/g, (all) => {
      return typeof replacements[all] !== 'undefined' ? replacements[all] : all
    })
  }
1 Like

This is to do with the ROBLOX group members not discord.

Thank you, I will mark this as a solution to make it easier for users to find if they are willing to change it over, just to simplify it.

Multiple users have said this, I’m sorry!

Sorry, I didn’t pay much attention to that, I will change it over when I get some time to update this.

Since its a free thing, its not the top of my priorities as I do also need to totally recode this thing :joy:.