Pegasus V1.1 Discord-FireBase-Roblox Ban Bot

Introduction

Hello, my name is GeneralLPrince and I decided to create a Discord to FireBase to Roblox ban bot called Pegasus that is used for game moderation from Discord, I got inspired to make this bot because of @dudeSafiyur1234 Discord-Trello-Roblox Ban bot Discord-Trello-Roblox Ban bot

I will be using repl.it and uptimerobot to host my bot and Firebase to store the data.

Commands
There are 2 commands currently but I am planning to add more commands in the future.

  1. !ban [Username] [Reason]

  2. !unban [Username]

You will be able to customize the prefix in the code

Setting up the bot
Go to https://repl.it/ and then create a new repl by pressing the blue square that will be found in the top right of your screen next to the Upgrade option.
image

After that, a UI will appear with 2 options ‘‘Create new repl’’ and a ‘‘Import from GitHub’’. We going for ‘‘Import from Github’’ once you select it, copy and paste this github.com/GeneralLPrince/Discord-Firebase-Roblox then start importing the Github.

Once you imported from Github, you will see this:


Change the language from Bash to node.js and press done then wait until your repl upgrades to Node.js and enter command to node index.js

Then go to index.js and scroll down to line 10 and edit what you must
image

The last step will be editing the .env file by creating a RealTime database in Firebase.
Firstly, if aren’t signed up in FireBase please do. Here is the link: https://firebase.google.com/

Once you sign up or login, create a new Firebase project and name your project to anything.
image
Go to Develop> Realtime Database and create a new Database and choose Start in Test mode
image


Congratulations, you just made a database in Firebase. Now we going back to repl.it to edit the .env file

image

Replace Your-Discord-Bot-Token with your bot token

Replace Your-Firebase-Server-Key with your firebase server key by going to project settings>Cloud Messaging>Server key and copy the key and paste it there

Replace PROJECT-NAME.firebaseapp.com with your ProjectName.firebaseapp.com

Replace YOUR-FIREBASE-DATABASE-URL with your Database URL by going to your RealTime Database>Data and then copy the link and paste it there

image

Once you edit the .env file you can run the project and it should work. if there were any errors or the bot didn’t work, please feel free to reply or DM in Discord. Prince#5191

How to host your bot 24/7H
Go to https://uptimerobot.com/ and login or signup.
Once you logged in your account, press + Add a new monitor then change the monitor type as HTTP(s), name your project to any name you prefer and then your URL (or IP) is https://ProjectName.username.repl.co

image


Once you’re done it should look like this:
image

Last Step
And now, we finally reached the last step of this tutorial, Download the RBXM file below that contains a script and a Firebase API provided by @MXKhronos.

The script and the API should be in ServerScriptServices and remember to enable HTTPs

View the module named “Firebase Service” and edit line 31 and 32 then you’re good to go.

Discord-Firebase-Roblox.rbxm (4.1 KB)

Note:
Thanks to everyone who is viewing this tutorial, if you have any ideas or suggestions for me to add to the bot please feel free to tell me them by replying. As I said before, if there were any errors or complications please direct message me in discord Prince#5191 or make a reply here.

Credits to: @MXKhronos for the Firebase API

Thank you again,

18 Likes

I don’t really want to rain on your parade but your method of banning isn’t very effective.

  1. One group might have more than one protected group i.e. moderators, admins etc.
  2. You can’t trust people to not change things that they don’t understand.

You’re also using a noblox api that is only called in the ban/unban commands. I went through the entire code and I don’t see any authentication api written into the code, making noblox useless unless you’re planning on adding authentication in the future (which you haven’t disclosed anywhere).

Best way to go about making sure you don’t ban protected roles is simply checking if they have certain permissions/position of the role on the roles table. Here’s a snippet of code from my old bot:

const bUser = args[0]
              bUser = message.mentions.members.first();
        if(!message.member.permissions.has('BAN_MEMBERS')) return message.reply("you don't have enough permissions to do that");

        if(bUser.permissions.has('BAN_MEMBERS')) return message.reply("you don't have enough permissions to do that");

        if(message.author.id === bUser.id) return message.reply("why are you trying to ban yourself?")
      
        if (!bUser) return message.reply(`invalid usage. Please do "ban [mention user]"`);
        bUser.ban({
            reason: `banned by ${message.author.tag}`
        });

        message.channel.send(`Looks like ${message.mentions.members.last()} won't be with us anymore!`).then(msg => {
            msg.delete(5000)
        })

Here the bot checks if the user who’s triggering the command has ban permissions, the banned member has permissions to ban (protected user) and if the command was triggered properly. Then it bans the user and adds a message to the Discord audit logs stating that X banned the user. It is definitely more effective than just having a role name that could be easily bypassed.

Please also note that the code is like 3 years old and might not work properly anymore…

3 Likes

Sorry for a late response but, I use Noblox API to check if the player exists in Roblox, if not the bot responds with ''User does not exist, please use this format: `!ban [Username][banReason]" else if the player does exist in Roblox and the moderator has permissions to ban, the bot will create a new data in firebase with the reason and the moderator name and tag.
image
image

Like I said, you only call for noblox API when banning so there’s no real reason for it… you’re making a bot that doesn’t have the functionality it actually need. The bot is defunct unless (like I already said) you’re adding authentication API to it now.

1 Like

Not really? There is a reason why I used noblox API for example to get the player id from the player username and check if the player exists in Roblox like I said before.

1 Like

Could you explain it to me in depth? Like I said, assuming from what I saw in the code itself, noblox is absolutely useless…

Yes I could. I made it so you only need the player username and a reason when banning for example: !ban GeneralLPrince Exploiting. The bot will use noblox API to get the Player Id from the suspect GeneralLPrince.

I also use noblox API to check if the suspect exists in Roblox

1 Like

Banned from where? The game you haven’t linked to? The discord server that doesn’t even have the authentication api in it?

What you mean? The player will be banned in your game if you linked the script I provided with your firebase data.

The bot will create a new data in FireBase with the ban informations for example: The player ID, the moderator and the reason why they got banned. When a banned player joins the game the script that I provided above will kick them and state why they got kicked and who banned them.

I still don’t know what you trying to expain but very much there is a reason why I am using noblox API

If you want me to explain you in detail how my bot works I would love to

Could you point that out in the code itself starting from setting up the place ID?
I went through the code again and there’s no mention of Place or game ID in index.js nor in your env file and only Auth it’s calling for is fire base related…




2 Likes

The code what you seeing is the code that handles the bot only. It doesn’t kick or ban the player since I think that’s impossible? I provided a RBXM file that contains 2 scripts, a script and a firebase API by @MXKhronos.

Basically what it does is, everytime a new player joins the game, the script will tell the API to check if the player user Id is found in the database. If the player had a data then it kicks them from the game.

1 Like

And Like @GeneralLPrince said, Noblox Is to GET the Targets UserId

1 Like

edit: sorry, i didn’t mean to reply to you i thought i was commenting on the main post

The 3rd party site aspect of this would be daunting to set up in my personal opinion, and can be avoided completely, in other words this can also be done using a simple webhook and Messaging Service. Along with storing bans you can use a datastore to store any bans given from users.

IE:

   local commands = game:GetService("MessagingService")

function(user, mod, context)
    	commands:PublishAsync("banusers",user,context)
        
    local bambi = {
    		["username"] = ("User Was Banned"),
    		["content"] = ("User**"..name.."** was **banned** by **"..moduser.."** **"..(context).."**."),
    	}
    	bambi= http:JSONEncode(bambi)
    	http:PostAsync("Discord Webhook", bambi)

(Of course with more detail you’d have a full logging and ban system via Roblox To Discord)

1 Like

Edit: Ops sorry there was a misunderstanding

1 Like

In the part where it says that anyone with the database reference can view, edit, and deleted data in 30 days. After those 30 days are over, I think it’ll default to block all requests to the database until the end user writes rules for it. The reason why I know is because I did this before for a Discord bot and it said in an email that all requests after 30 days will be blocked, so unless they changed this, it’ll be this case.

For anyone who is having trouble with opening the RBXM file here is a model instead https://www.roblox.com/library/5665349066/Firebase-Roblox-Ban-script

Side note: I have many plans for Pegasus so I would like to announce some of the plans that I would like everyone to know.

I am planning to transform Pegasus into a closed-source public bot, whoever I am still gonna keep the V1 of the bot open-sourced and still offer support for it. I will also include many more commands such as verification, group functions like exile, promote, set rank, demote, accept joins requests, and shouts.

Whoever, due to school started this might take time. Anyways, I am always open to suggestions and I would love to offer support to anyone.

My Discord user: Prince#5191

Where can I find my Authenticaion Token for the RBX model?

You will find your Firebase Authentication Token here:

1 Like