Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var discord = require('discord.js');
- var bot = new discord.Client();
- var prefix = "-"
- var roblox = require('roblox-js')
- var maximumRank = 14
- var groupId = 4105355
- roblox.login({username: "Virtuals_Bot", password: "FlAmInDyScPf"}).then((success) => {
- }).catch(() => {console.log("Failed to login.");});
- process.on('unhandledRejection', (reason, promise) => {
- console.log('Unhandled Rejection at:', reason.stack || reason)
- // Recommended: send the information to sentry.io
- // or whatever crash reporting service you use
- })
- async function purge(messageamount,message,delay) {
- if (message) {
- if (delay) {
- message.delete(delay);
- }
- else {
- message.delete();
- }
- }
- const fetched = await message.channel.fetchMessages({limit: messageamount});
- message.channel.bulkDelete(fetched);
- }
- bot.on('ready', () => {
- var msg = bot.guilds.first().channels.find(channel => channel.name === "on-topic").send("Starting up KAI.").then((msg)=>{
- msg.react("🎉")
- msg.edit("Please wait.. starting up [REDACTED]")
- msg.edit("Grabbing information from webserver 192.0.0.1..")
- msg.edit("Estabilishing connection..")
- msg.edit("Connection estabilished. ")
- msg.edit("Grabbing data from subserver main/517868117087617048.")
- msg.edit("7%")
- msg.edit("9%")
- msg.edit("14%")
- msg.edit("17%")
- msg.edit("20%")
- msg.edit("28%")
- msg.edit("32%")
- msg.edit("39%")
- msg.edit("45%")
- msg.edit("67%")
- msg.edit("68%")
- msg.edit("74%")
- msg.edit("82%")
- msg.edit("95%")
- msg.edit("100%")
- msg.edit("Done. Started up.")
- msg.delete()
- })
- });
- bot.on("guildMemberAdd", member => {
- member.user.send("Hey there, " + member.username + "! Welcome to Flamindy's SCPF!")
- setTimeout(function(){
- var username = member.nickname
- roblox.getIdFromUsername(username)
- .then(function(id){
- roblox.getRankNameInGroup(groupId, id)
- .then(function(rank){
- const role = message.guild.roles.find("name", rank)
- .then(function(role){
- message.author.member.addRole(role);
- })
- })
- })
- }, 15000);
- });
- bot.on('message', (message) => {
- if (message.author.bot) return;
- if (message.content.startsWith(prefix)) {
- var args = message.content.slice(prefix.length).split(/ +/);
- var command = args.shift().toLowerCase();
- var sentBy = message.author.username
- var mention = message.mentions.first
- console.log('Command: ' + command)
- console.log(args);
- if (command == "acceptjoin") {
- var username = args[0]
- if (username) {
- message.channel.send("Checking for user " + username + "..")
- roblox.getIdFromUsername(username)
- .then(function(id){
- message.channel.send("Found! Attempting to handle the join request now.")
- roblox.handleJoinRequest(groupId,id,true)
- .then(function(yes) {
- message.channel.send("Accepted!")
- }
- )
- })
- } else {
- message.channel.send("No username!")
- }}
- if (command == "demote") {
- var username = args[0]
- 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 demoteable.`)
- } else {
- message.channel.send(`${id} is rank ${rank} and demoteable.`)
- roblox.demote(groupId, id)
- .then(function(roles){
- message.channel.send(`Demoted from ${roles.oldRole.Name} to ${roles.newRole.Name}`)
- }).catch(function(err){
- message.channel.send("Failed to demote.")
- });
- }
- }).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 (command == "promote") {
- var username = args[0]
- 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 (command == "setrank") {
- var username = args[0]
- if (username) {
- message.channel.send("Checking for user " + username + "..")
- roblox.getIdFromUsername(username)
- .then(function(id){
- message.channel.send("Found! Attempting to handle the rank change request now.")
- roblox.setRank(groupId,id,args[1])
- })
- } }
- if (command == "") {
- }
- }
- });
- bot.login('NTE5NTM1MzY1MDA3MDgxNDcy.Dug2Sg.c5oYyJdNYGIQN8xz3IsHho_Z9yY');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement