Need someone to tweak a script for me


#1

So I'm trying to create this ROBLOX PM Bot, but I also want to make it send friend requests. Do you think you can edit the script, so it works? I think most of the script is fine, it's just the send friend request portion that doesn't function. Here it is, so far...

function action(userId, username) {
sendMsg(userId, username);

$.post("https://www.roblox.com/api/friends/sendfriendrequest",{
targetUserID : userId
}).complete(function(){
console.log('Sent request to ' + username + '.')
})
}

const subject = "Avoid ROBLOX scams! (PLEASE READ)"; // Subject of the message.
const body = "Attention, &un. If you have received messages on how to get free robux, do NOT trust these sites. All of them are fake. They’ll use your αᑕᑕᗝυɴт ιɴғᗝᖇмαтιᗝɴ to your advantage, and could steal all of your robux. Some of these are 𝐩𝐡𝐢𝐬𝐡𝐢𝐧𝐠 sites, which can put you at risk for getting hacked. Avoid them no matter what. There’s a chance they’ll track your Iᑭ, and leak out your ᏢᎪssᎳᎾᏒᎠ. Sites with links such as 𝒓𝒐𝒃𝒍𝒐𝒙.𝒄𝒐𝒎.𝒎𝒙 are examples. People will even go as far as to posing as the ROBLOX Corporation. If you get an ɛʍǟɨʟ acting as info@roblox.com, or a similar one asking for αᑕᑕᗝυɴт ιɴғᗝ ignore it. Chances are, it’ll redirect you to another site.\n\n\ ROBLOX can still look at your account without logging in. Those who claim that their games give out free robux are also lying. Some of them have suspicious ĞÚĨs. The games are cleverly made to have fake players and admins. Don’t trust the chat, because it’s all scripted too. Liking and 𝕗𝕒𝕧𝕠𝕦𝕣𝕚𝕥𝕚𝕟𝕘 them does nothing. Keep in mind, there are legitimate groups that do donate robux. A lot of groups also lie, and are desperate for members. Tired of getting more messages? Changing your message settings, from “Everyone” to “Friends” can reduce the amount of spam you get. Report these accounts if you happen to see them. Follow me if you want to show your support. Have fun, and remember to stay safe on ᖇOᗷᒪO᙭. \n\n\ 5 Tips to Keep Your ROBLOX Account Safe:\n\n\ https://blog.roblox.com/2016/10/5-tips-to-keep-your-roblox-account-safe/\n\n\ 2-Step Verification:\n\n\ https://blog.roblox.com/2016/09/roblox-introduces-2-step-verification/\n\n\ Sincerely,\n\n\ R0BL0X Help Bot\n\n\ P.S. I am not affiliated with ROBLOX staff (If you still don’t know what this means, I’m not an admin)"; // Body of the message

const GameID = 90267357; // ID of the game to locate players to message.
const excludedGroups = []// IDs of group whose members won't be messaged.
const senderPause = 1; // Wait time in seconds after successfully sending a message.

/////////////////////////////////////////////////////////

// Leave these alone.
var servers = [];
var GameName = '';
var msgCount = 0;

function finishProcess(serverIndex, playerIndex) {
if (playerIndex + 1 == servers[serverIndex].CurrentPlayers.length) {
if (serverIndex + 1 != servers.length) {
msgNext(serverIndex + 1, 0);
} else {
console.log('Finished!\nTotal messages sent: ' + msgCount);
}
} else {
msgNext(serverIndex, playerIndex + 1);
}
}

function sendMsg(serverIndex, playerIndex, player, passed) {
if (passed === true) {
$.post('https://www.roblox.com/messages/send', {
subject : subject.replace(/&un/gi, player.Username).replace(/&gn/gi, GameName),
body : body.replace(/&un/gi, player.Username).replace(/&gn/gi, GameName),
recipientid : player.Id,
cacheBuster : new Date().getTime()
}).done(function(response) {
if (response.success === true) {
console.log('Sent message to '+player.Username+'.');
msgCount += 1;
setTimeout(function() {
finishProcess(serverIndex, playerIndex);
}, senderPause*1000);
} else {
if (response.shortMessage == 'SenderFlooded') {
console.log('Sender is flooded. Retrying in '+senderPause+' second(s).');
setTimeout(function() {
sendMsg(serverIndex, playerIndex, player, true);
}, senderPause*1000);
} else {
console.log('Could not message '+player.Username+'. '+response.shortMessage+'.');
finishProcess(serverIndex, playerIndex);
}
}
});
} else {
if (passed !== false) {
console.log(passed);
}
finishProcess(serverIndex, playerIndex);
}
}

function groupCheck(serverIndex, playerIndex, groupIndex, player) {
$.get('https://www.roblox.com/Game/LuaWebService/HandleSocialRequest.ashx?method=IsInGroup&playerid='+player.Id+'&groupid='+excludedGroups[groupIndex], function(response) {
if (response.indexOf('true') != -1) {
sendMsg(serverIndex, playerIndex, player, player.Username+' is in an excluded group.');
} else {
if (excludedGroups.length > groupIndex + 1) {
groupCheck(serverIndex, playerIndex, groupIndex + 1, player);
} else {
sendMsg(serverIndex, playerIndex, player, true);
}
}
});
};

function msgNext(serverIndex, playerIndex) {
var player = servers[serverIndex].CurrentPlayers[playerIndex];
if (player.Id > 0) {
if (excludedGroups.length > 0) {
groupCheck(serverIndex, playerIndex, 0, player);
} else {
sendMsg(serverIndex, playerIndex, player, true);
}
} else {
sendMsg(serverIndex, playerIndex, player, false);
}
}

// Getting the list of servers prevents users from being messaged twice.
function getServers(startIndex) {
var serversURL = ('https://www.roblox.com/games/getgameinstancesjson?placeId='+GameID+'&startIndex='+startIndex);
$.get(serversURL).done(function(obj) {
for (var server in obj.Collection) {
servers.push(obj.Collection[server]);
}
if (obj.Collection.length > 0) {
getServers(startIndex+10);
} else {
console.log('Ready to send messages.');
msgNext(0, 0);
}
});
}

console.log('Starting bot.');

$.get('https://www.roblox.com/place-thumbnails?params=[{placeId:'+GameID+'}]').done(function(response) {
GameName = response[0].name;
console.log('Obtaining list of servers for '+GameName+'. Please wait.');
getServers(0);
});


#2

If you still don't know what I'm talking about, I want this part fixed. How come the when I run it, Google Inspect doesn't recognize this?

function action(userId, username) {
sendMsg(userId, username);

$.post("https://www.roblox.com/api/friends/sendfriendrequest",{
targetUserID : userId
}).complete(function(){
console.log('Sent request to ' + username + '.')
})
}


#3

You ever fix it? I'm intrested!


#4

I can’t really help as I am very clueless about most knowledge of programming.
However my future career is highly devoted to IT and Technology Business. This year I’ll be taking programming lessons and classes, possibly creating games.

Even though I can’t help, I have a question for you.
May I use this without the friend request sending option?
Does it work without that or does it still execute without error?

I’ve read over it a couple times and have a bit of knowledge but don’t see where I would put my message or how to use it without the friend request section.