Guest User

error

a guest
Dec 24th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // DEPENDANCIES
  2. let Discord = require('discord.js');
  3. let roblox = require('roblox-js');
  4. let bot = new Discord.Client(); // A client that we will use as our bot
  5.  
  6. // LOGIN INFO
  7. let token = "DISCORD_TOKEN_HERE"; // Discord login token
  8. let username = "username"; // ROBLOX
  9. let password = "password"; // ROBLOX
  10.  
  11. // MISC
  12. let PREFIX = "!" // Prefix used for the command
  13. let GroupId = 123456; // Group's ID
  14.  
  15.  
  16. // LOGIN FUNCTION
  17. function login() {
  18.     return roblox.login(username, password);
  19. }
  20.  
  21. login() // Log into ROBLOX
  22.     .then(function() { // After the function has been executed
  23.         console.log('Logged in.') // Log to the console that we've logged in
  24.     })
  25.     .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.
  26.         console.log(`Login error: ${error}`) // Log the error to console if there is one.
  27.     });
  28.  
  29. bot.on("message", async message => { // Event runs when there is a new message
  30.     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.
  31.     if (message.content.indexOf(prefix) !== 0) return; // Checks if the message has the Prefix
  32.  
  33.     // Here we separate our "command" and our "arguments/args" for the command.
  34.     const args = message.content.slice(prefix.length).trim().split(/ +/g);
  35.     const command = args.shift().toLowerCase();
  36.  
  37.     // Checks if the command is matching the provided string
  38.  
  39.     if (command === "shout") {
  40.         // if(!message.member.roles.some(r=>["ROLE", "ROLE"].includes(r.name)) ) // OPTIONAL - Checks if the sender has the specified roles to carry on further
  41.         //return message.reply("You can't use this command.");
  42.         if (!args) { // Check if there's no arguments to use to shout, and return (stop going further)
  43.             return;
  44.             message.reply('Please specify a message to shout.')
  45.         }
  46.         const shoutMSG = args.join(" "); // Joins the arguments minus prefix to form the message to be shouted
  47.  
  48.         roblox.shout(GroupId, shoutMSG)
  49.             .then(function() {
  50.                 console.log(`Shouted ${shoutMSG}`); // OPTIONAL - Logs specified string to the console
  51.                 // message.channel.send('Shouted to the group!') // OPTIONAL - Sends a message to the channel
  52.             })
  53.             .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.
  54.                 console.log(`Shout error: ${error}`) // Log the error to console if there is one.
  55.             });
  56.     }
  57. })
  58.  
  59. setInterval(login, 86400000); // Executes the login function every 24 hours.
  60.  
  61. bot.login(token) // Logs into Discord
Add Comment
Please, Sign In to add comment