Advertisement
Guest User

Untitled

a guest
Dec 5th, 2018
2,098
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.78 KB | None | 0 0
  1. var discord = require('discord.js');
  2. var bot = new discord.Client();
  3. var prefix = "-"
  4. var roblox = require('roblox-js')
  5. var maximumRank = 14
  6. var groupId = 4105355
  7. roblox.login({username: "Virtuals_Bot", password: "FlAmInDyScPf"}).then((success) => {
  8.  
  9. }).catch(() => {console.log("Failed to login.");});
  10. process.on('unhandledRejection', (reason, promise) => {
  11. console.log('Unhandled Rejection at:', reason.stack || reason)
  12. // Recommended: send the information to sentry.io
  13. // or whatever crash reporting service you use
  14. })
  15.  
  16. async function purge(messageamount,message,delay) {
  17. if (message) {
  18. if (delay) {
  19. message.delete(delay);
  20. }
  21. else {
  22. message.delete();
  23. }
  24. }
  25.  
  26. const fetched = await message.channel.fetchMessages({limit: messageamount});
  27. message.channel.bulkDelete(fetched);
  28. }
  29.  
  30. bot.on('ready', () => {
  31.  
  32. var msg = bot.guilds.first().channels.find(channel => channel.name === "on-topic").send("Starting up KAI.").then((msg)=>{
  33. msg.react("🎉")
  34. msg.edit("Please wait.. starting up [REDACTED]")
  35. msg.edit("Grabbing information from webserver 192.0.0.1..")
  36. msg.edit("Estabilishing connection..")
  37. msg.edit("Connection estabilished. ")
  38. msg.edit("Grabbing data from subserver main/517868117087617048.")
  39. msg.edit("7%")
  40. msg.edit("9%")
  41. msg.edit("14%")
  42. msg.edit("17%")
  43. msg.edit("20%")
  44. msg.edit("28%")
  45. msg.edit("32%")
  46. msg.edit("39%")
  47. msg.edit("45%")
  48. msg.edit("67%")
  49. msg.edit("68%")
  50. msg.edit("74%")
  51. msg.edit("82%")
  52. msg.edit("95%")
  53. msg.edit("100%")
  54. msg.edit("Done. Started up.")
  55. msg.delete()
  56. })
  57. });
  58. bot.on("guildMemberAdd", member => {
  59. member.user.send("Hey there, " + member.username + "! Welcome to Flamindy's SCPF!")
  60. setTimeout(function(){
  61.  
  62.  
  63. var username = member.nickname
  64. roblox.getIdFromUsername(username)
  65. .then(function(id){
  66. roblox.getRankNameInGroup(groupId, id)
  67. .then(function(rank){
  68. const role = message.guild.roles.find("name", rank)
  69. .then(function(role){
  70. message.author.member.addRole(role);
  71. })
  72. })
  73. })
  74.  
  75.  
  76. }, 15000);
  77. });
  78.  
  79. bot.on('message', (message) => {
  80.  
  81. if (message.author.bot) return;
  82. if (message.content.startsWith(prefix)) {
  83. var args = message.content.slice(prefix.length).split(/ +/);
  84.  
  85. var command = args.shift().toLowerCase();
  86. var sentBy = message.author.username
  87. var mention = message.mentions.first
  88. console.log('Command: ' + command)
  89. console.log(args);
  90.  
  91.  
  92.  
  93.  
  94. if (command == "acceptjoin") {
  95. var username = args[0]
  96. if (username) {
  97. message.channel.send("Checking for user " + username + "..")
  98. roblox.getIdFromUsername(username)
  99. .then(function(id){
  100. message.channel.send("Found! Attempting to handle the join request now.")
  101. roblox.handleJoinRequest(groupId,id,true)
  102. .then(function(yes) {
  103. message.channel.send("Accepted!")
  104. }
  105.  
  106. )
  107. })
  108. } else {
  109. message.channel.send("No username!")
  110. }}
  111. if (command == "demote") {
  112. var username = args[0]
  113. if (username){
  114. message.channel.send(`Checking ROBLOX for ${username}`)
  115. roblox.getIdFromUsername(username)
  116. .then(function(id){
  117. roblox.getRankInGroup(groupId, id)
  118. .then(function(rank){
  119. if(maximumRank <= rank){
  120. message.channel.send(`${id} is rank ${rank} and not demoteable.`)
  121. } else {
  122. message.channel.send(`${id} is rank ${rank} and demoteable.`)
  123. roblox.demote(groupId, id)
  124. .then(function(roles){
  125. message.channel.send(`Demoted from ${roles.oldRole.Name} to ${roles.newRole.Name}`)
  126. }).catch(function(err){
  127. message.channel.send("Failed to demote.")
  128. });
  129. }
  130. }).catch(function(err){
  131. message.channel.send("Couldn't get him in the group.")
  132. });
  133. }).catch(function(err){
  134. message.channel.send(`Sorry, but ${username} doesn't exist on ROBLOX.`)
  135. });
  136. } else {
  137. message.channel.send("Please enter a username.")
  138. }
  139. return;
  140. }
  141. if (command == "promote") {
  142. var username = args[0]
  143. if (username){
  144. message.channel.send(`Checking ROBLOX for ${username}`)
  145. roblox.getIdFromUsername(username)
  146. .then(function(id){
  147. roblox.getRankInGroup(groupId, id)
  148. .then(function(rank){
  149. if(maximumRank <= rank){
  150. message.channel.send(`${id} is rank ${rank} and not promotable.`)
  151. } else {
  152. message.channel.send(`${id} is rank ${rank} and promotable.`)
  153. roblox.promote(groupId, id)
  154. .then(function(roles){
  155. message.channel.send(`Promoted from ${roles.oldRole.Name} to ${roles.newRole.Name}`)
  156. }).catch(function(err){
  157. message.channel.send("Failed to promote.")
  158. });
  159. }
  160. }).catch(function(err){
  161. message.channel.send("Couldn't get him in the group.")
  162. });
  163. }).catch(function(err){
  164. message.channel.send(`Sorry, but ${username} doesn't exist on ROBLOX.`)
  165. });
  166. } else {
  167. message.channel.send("Please enter a username.")
  168. }
  169. return;
  170. }
  171.  
  172. if (command == "setrank") {
  173. var username = args[0]
  174. if (username) {
  175. message.channel.send("Checking for user " + username + "..")
  176. roblox.getIdFromUsername(username)
  177. .then(function(id){
  178. message.channel.send("Found! Attempting to handle the rank change request now.")
  179.  
  180. roblox.setRank(groupId,id,args[1])
  181. })
  182. } }
  183. if (command == "") {
  184.  
  185. }
  186. }
  187.  
  188. });
  189. bot.login('NTE5NTM1MzY1MDA3MDgxNDcy.Dug2Sg.c5oYyJdNYGIQN8xz3IsHho_Z9yY');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement