Guide to Scripting Bots | Javascript Tutorial | FunCaptcha and New Host Info

I used glitch for this and I’m wondering, for the require part would I replace the herokuapp part with the glitch url instead? I currently have this…

local bot = require(script.BotServer)(
	"suufi-noblox-js-server-3.glitch.me", 
	key,
	groupId
)

but when I try to use .setRank(), it gives me a 405 error

I’d have to look into how their web hosting works for API’s. Currently it’s no issue if it’s just only a bot but I’m not sure it’s usable for web hosting so you might be out of luck there.

1 Like

I have been using glitch for the past few days to run express + MongoDB and have been sending HTTP requests. It works perfectly fine with no issues.

2 Likes

what url do you send it to

my-app.glitch.me/myendpoint

For example if my endpoints for shouting to a group are set up as /api/groupShout/, I’ll send the request to my-app.glitch.me/api/groupShout/

1 Like

okay I redid the glitch server because I did the express server instead of the sqlite one, and now it’s showing this error “{“error”:“Server configuration error: You are not logged in.”}”

Wait, you posted this and told me to use the noblox.js-server, but am I supposed to add noblox.js somehow?

Well, actually there are some ways to still login and bypass / autosolve the captcha. I do not recommend this though because you can easily implement the client sided captcha of roblox on your own website to let users validate their fun captcha token themselves without a bypass.

lol where do I put the scripts that’s what I don’t understand

If you read the guide is says exactly where things go.

Awesome tutorial!

Thanks! The tutorial is very easy to understand.

2 Likes

Is it possible to use functions in the javascript modules when my bot is running in Lua? I’m using the Discordia module to control my bot, but I’d like to be able to control my noblox-js module with Lua (running on Luvit).

Yea, you can make a Rest API, or use a thing like @Reselim 's engine.io library that can communicate with roblox in real time.

I believe he/she meant running Lua not on Roblox, but as an individual program.

@bigcrazycarboy You have a couple of options; you can run both programs and then have some sort of IPC between the two processes, or you could use something like https://fengari.io/ to run Lua in Node.JS (Lua VM).

1 Like

I’m using Luvit as my VM at the moment, and since that has custom built-in functions it would be hard to switch. To my understanding Luvit is open sourced on github, so if needed I could copy some stuff over, but ultimately I’d like to avoid having to do that.

1 Like

Not without more effort than it’s worth, unfortunately.

UPDATED CODE

var discord = require('discord.js');
var roblox = require('noblox.js');
var client = new discord.Client();
var token = "TOKEN_HERE"
var cookie = "COOKIE HERE"
client.login(token)

roblox.cookieLogin(cookie).catch(() => {console.log("Sorry, it failed.");});


client.on("ready", () => {
  client.user.setGame(`Making HL3`);
  console.log(`Ready to serve on ${client.guilds.size} servers, for ${client.users.size} users.`);
});

client.on('guildMemberAdd', member => {
  let guild = member.guild;
  let user = member.user
  console.log(`${user.tag} joined ${guild}`)
});

client.on('guildMemberRemove', member => {
  let guild = member.guild;
  let user = member.user
  console.log(`${user.tag} left ${guild}`)
});

var prefix = '!';
var groupId = 2750654;
var maximumRank = 20;

function isCommand(command, message){
	var command = command.toLowerCase();
	var content = message.content.toLowerCase();
	return content.startsWith(prefix + command);
}

client.on('message', (message) => {
	if (message.author.bot) return; // Dont answer yourself.
    var args = message.content.split(/[ ]+/)
    
    if(isCommand('Promote', message)){
    	var username = args[1]
    	if (username){
    		message.channel.send(`Checking ROBLOX for ${username}`)
    		roblox.getIdFromUsername(username)
			.then(function(id){
				roblox.getRankInGroup(groupId, id)
				.then(function(rank){
					if(maximumRank <= rank){
						message.channel.send(`${id} is rank ${rank} and not promotable.`)
					} else {
						message.channel.send(`${id} is rank ${rank} and promotable.`)
						roblox.promote(groupId, id)
						.then(function(roles){
							message.channel.send(`Promoted from ${roles.oldRole.Name} to ${roles.newRole.Name}`)
						}).catch(function(err){
							message.channel.send("Failed to promote.")
						});
					}
				}).catch(function(err){
					message.channel.send("Couldn't get him in the group.")
				});
			}).catch(function(err){ 
				message.channel.send(`Sorry, but ${username} doesn't exist on ROBLOX.`)
			});
    	} else {
    		message.channel.send("Please enter a username.")
    	}
    	return;
    }



if(isCommand('Shout', message)){    
const msg = message;
    var Moderator = msg.author;
    ShoutMessage = args.join(" ");
    if (ShoutMessage) {
      rbx.shout({group: groupId, message: ShoutMessage}).then(promise => { 
      MessageEmbed(Moderator, 0X42F47A, 'Sucessfully shouted to the Group!\n\nMessage: `' + ShoutMessage + '`');
      })
    } else {
      MessageEmbed(Moderator, 0XFF5151, 'Please provide a shout message.\n\nUsage: `shout <message>`');
    };
  


function MessageEmbed(Mod1, Color, Description) {
    var embed = new Discord.MessageEmbed()
        .setAuthor(Mod1.tag, Mod1.displayAvatarURL())
        .setColor(Color)
        .setDescription(Description);
    msg.channel.send({ embed });

}

});```

*NOTE I will Replace this with better code with Handlers etc later.*
8 Likes

The cookie expires every 24 hours, noblox automatically refreshes the cookie right?

My cookie has lasted 5 Months.

That’s strange, my cookie keeps resetting or something… is this because of the browser? I am using Chromium on a RPI3B.

Go to Chrome > Private Tab > and then gert your cookie from there.