Guide to Scripting Bots | Javascript Tutorial

scripting
clans
bot
bots
javascript

#41

I’m getting pretty disappointed to see that there are no updates at all for weeks.


#42

GUIDE TO SHOUTING THROUGH DISCORD

Apologies for the late update, as promised here it is.

(This is a part of this thread, approved by Tech)

Note: This is strictly for a tutorial basis and is not to be used in any way that could potentially be harmful. Remember to stay in keeping with the ROBLOX rules!

Have fun! DM me or reply for answers to any questions you may have. I tried my best to comment most of the code to explain the function the line had.

// DEPENDANCIES
let Discord = require('discord.js');
let roblox = require('roblox-js');
let bot = new Discord.Client(); // A client that we will use as our bot

// LOGIN INFO
let token = "DISCORD_TOKEN_HERE"; // Discord login token
let username = "username"; // ROBLOX
let password = "password"; // ROBLOX

// MISC
let PREFIX = "!" // Prefix used for the command
let GroupId = 123456; // Group's ID


// LOGIN FUNCTION
function login() {
    return roblox.login(username, password);
}

login() // Log into ROBLOX
    .then(function() { // After the function has been executed
        console.log('Logged in.') // Log to the console that we've logged in
    })
    .catch(function(error) { // This is a catch in the case that there's an error. Not using this will result in an unhandled rejection error.
        console.log(`Login error: ${error}`) // Log the error to console if there is one.
    });

bot.on("message", async message => { // Event runs when there is a new message
    if (message.author.bot) return; // Here we check if the message sender is the bot, if it is, it returns and does not carry any further.
    if (message.content.indexOf(prefix) !== 0) return; // Checks if the message has the Prefix

    // Here we separate our "command" and our "arguments/args" for the command. 
    const args = message.content.slice(prefix.length).trim().split(/ +/g);
    const command = args.shift().toLowerCase();

    // Checks if the command is matching the provided string

    if (command === "shout") {
        // if(!message.member.roles.some(r=>["ROLE", "ROLE"].includes(r.name)) ) // OPTIONAL - Checks if the sender has the specified roles to carry on further
        //return message.reply("You can't use this command.");
        if (!args) { // Check if there's no arguments to use to shout, and return (stop going further)
            return;
            message.reply('Please specify a message to shout.')
        }
        const shoutMSG = args.join(" "); // Joins the arguments minus prefix to form the message to be shouted

        roblox.shout(GroupId, shoutMSG)
            .then(function() {
                console.log(`Shouted ${shoutMSG}`); // OPTIONAL - Logs specified string to the console
                // message.channel.send('Shouted to the group!') // OPTIONAL - Sends a message to the channel
            })
            .catch(function(error) { // This is a catch in the case that there's an error. Not using this will result in an unhandled rejection error.
                console.log(`Shout error: ${error}`) // Log the error to console if there is one.
            });
    }
})

setInterval(login, 86400000); // Executes the login function every 24 hours.

bot.login(token) // Logs into Discord
  • I found this easy to follow
  • I had trouble following this

0 voters


#43

Finally, Good tutorial.


#44

This isn’t a good implementation because the user is logged in all over again every time a shout is made when really you just need to login once at the top of the script and have an interval running once a day to re log in. If used often Roblox will block logging in with a captcha.


#45

Alright I’ll edit it when I get the chance.


#47

If you guys want any more tutorials to be made, don’t be afraid to ask here.


#48

Made something like this on my own, you did a pretty good job of explaining it! Should maybe make it so it keeps the original shout but adds on its own part. So like lets say u had a shout “Play Now!! www.roblox.com” and then the bot added on to the shout and made it “Play Now!! www.roblox.com - Hello there!” and when a new shout is made it finds the “-” removes everything after it and sets it to the new shout. Thats how I do it anyways!


#49

When I did the “git add” it just said “No such file or directory.”


#50

Make sure your directory in your cmd/terminal is the directory your bot will be in, then do

git add .

Make sure to include the .