Advertisement
Guest User

Untitled

a guest
Dec 7th, 2018
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.62 KB | None | 0 0
  1. var discord = require('discord.js');
  2. var bot = new discord.Client();
  3. var prefix = "-";
  4. const Enmap = require('enmap')
  5. const ffmpeg = require("ffmpeg")
  6. const ffmpegbinaries = require("ffmpeg-static")
  7.  
  8.  
  9. var roblox = require('roblox-js');
  10. var opus = require('opusscript')
  11. var ytdl = require('ytdl-core')
  12. var maximumRank = 14;
  13. var servers = {};
  14. var groupId = 4105355;
  15. var queue = new Enmap({name: "queue"});
  16. roblox.login({username: "Virtuals_Bot", password: "yeah not for you this is not the real password ofc"}).then((success) => {
  17.  
  18. }).catch(() => {console.log("Failed to login.");});
  19. process.on('unhandledRejection', (reason, promise) => {
  20. console.log('Unhandled Rejection at:', reason.stack || reason)
  21. // Recommended: send the information to sentry.io
  22. // or whatever crash reporting service you use
  23. });
  24. function play(connection2,message) {
  25. message.member.voiceChannel.join().then(connection => {
  26.  
  27.  
  28.  
  29.  
  30. var server = queue
  31. message.channel.send("Added to queue!")
  32. var stream = ytdl(server[0], {filter: 'audioonly'})
  33. server.shift()
  34. queue.set("queue",server)
  35. server.dispatcher = connection.playStream(stream)
  36.  
  37. server.dispatcher.on("end",function(){
  38.  
  39. if (server[0]) {
  40. message.channel.send("Now playing: " + server[0])
  41. play(connection,message)
  42. } else {
  43. message.channel.send("Queue over!")
  44. connection.disconnect()
  45. }
  46. })})
  47. }
  48. async function purge(messageamount,message,delay) {
  49. if (message) {
  50. if (delay) {
  51. message.delete(delay);
  52. }
  53. else {
  54. message.delete();
  55. };
  56. };
  57.  
  58. const fetched = await message.channel.fetchMessages({limit: messageamount});
  59. message.channel.bulkDelete(fetched);
  60. };
  61.  
  62. bot.on('ready', () => {
  63.  
  64. var msg = bot.guilds.first().channels.find(channel => channel.name === "on-topic").send("Starting up KAI.").then((msg)=>{
  65.  
  66. msg.delete()
  67. })
  68. });
  69. bot.on("guildMemberAdd", member => {
  70. member.user.send("Hey there, " + member.username + "! Welcome to Flamindy's SCPF!")
  71. setTimeout(function(){
  72.  
  73.  
  74. var username = member.nickname
  75. roblox.getIdFromUsername(username)
  76. .then(function(id){
  77. roblox.getRankNameInGroup(groupId, id)
  78. .then(function(rank){
  79. const role = message.guild.roles.find("name", rank)
  80. .then(function(role){
  81. message.author.member.addRole(role);
  82. })
  83. })
  84. })
  85.  
  86.  
  87. }, 15000);
  88. });
  89.  
  90. bot.on('message', (message) => {
  91. if (message.content == "Please type your message!") {message.delete()}
  92. if (message.author.bot) return;
  93. if (message.content.startsWith(prefix)) {
  94. var args = message.content.slice(prefix.length).split(/ +/);
  95.  
  96. var command = args.shift().toLowerCase();
  97. var sentBy = message.author.username
  98. var mention = message.mentions.first
  99. console.log('Command: ' + command)
  100. console.log(args);
  101.  
  102.  
  103.  
  104.  
  105. if (command == "acceptjoin") {
  106. if (message.member.roles.has('519954873001967639')) {
  107. var username = args[0]
  108. if (username) {
  109. message.channel.send("Checking for user " + username + "..")
  110. roblox.getIdFromUsername(username)
  111. .then(function(id){
  112. message.channel.send("Found! Attempting to handle the join request now.")
  113. roblox.handleJoinRequest(groupId,username,true)
  114. .then(function(yes) {
  115. message.channel.send("Accepted!")
  116. }
  117.  
  118. )
  119. })
  120. } else {
  121. message.channel.send("No username!")
  122. }}}
  123. if (command == "demote") {
  124. if (message.member.roles.has('519954873001967639')) {
  125. var username = args[0]
  126. if (username){
  127. message.channel.send(`Checking ROBLOX for ${username}`)
  128. roblox.getIdFromUsername(username)
  129. .then(function(id){
  130. roblox.getRankInGroup(groupId, id)
  131. .then(function(rank){
  132. if(maximumRank <= rank){
  133. message.channel.send(`${id} is rank ${rank} and not demoteable.`)
  134. } else {
  135. message.channel.send(`${id} is rank ${rank} and demoteable.`)
  136. roblox.demote(groupId, id)
  137. .then(function(roles){
  138. message.channel.send(`Demoted from ${roles.oldRole.Name} to ${roles.newRole.Name}`)
  139. }).catch(function(err){
  140. message.channel.send("Failed to demote.")
  141. });
  142. }
  143. }).catch(function(err){
  144. message.channel.send("Couldn't get him in the group.")
  145. });
  146. }).catch(function(err){
  147. message.channel.send(`Sorry, but ${username} doesn't exist on ROBLOX.`)
  148. });
  149. } else {
  150. message.channel.send("Please enter a username.")
  151. }
  152. return;
  153. }}
  154. if (command == "promote") {
  155. if (message.member.roles.has('519954873001967639')) {
  156. var username = args[0]
  157. if (username){
  158. message.channel.send(`Checking ROBLOX for ${username}`)
  159. roblox.getIdFromUsername(username)
  160. .then(function(id){
  161. roblox.getRankInGroup(groupId, id)
  162. .then(function(rank){
  163. if(maximumRank <= rank){
  164. message.channel.send(`${id} is rank ${rank} and not promotable.`)
  165. } else {
  166. message.channel.send(`${id} is rank ${rank} and promotable.`)
  167. roblox.promote(groupId, id)
  168. .then(function(roles){
  169. message.channel.send(`Promoted from ${roles.oldRole.Name} to ${roles.newRole.Name}`)
  170. }).catch(function(err){
  171. message.channel.send("Failed to promote.")
  172. });
  173. }
  174. }).catch(function(err){
  175. message.channel.send("Couldn't get him in the group.")
  176. });
  177. }).catch(function(err){
  178. message.channel.send(`Sorry, but ${username} doesn't exist on ROBLOX.`)
  179. });
  180. } else {
  181. message.channel.send("Please enter a username.")
  182. }
  183. return;
  184. }}
  185.  
  186. if (command == "setrank") {
  187. if (message.member.roles.has('519954873001967639')) {
  188. var username = args[0]
  189. if (username) {
  190. message.channel.send("Checking for user " + username + "..")
  191. roblox.getIdFromUsername(username)
  192. .then(function(id){
  193. message.channel.send("Found! Attempting to handle the rank change request now.")
  194.  
  195. roblox.setRank(groupId,id,args[1])
  196. })
  197. } }}
  198. if (command == "announce") {
  199. if (message.member.roles.has('519954873001967639')) {
  200. if (args[0] && args[1]) {
  201. var channel = message.mentions.channels.first()
  202. message.channel.send("Please type the desired announcement. Say cancel to cancel.")
  203. .then(function(){
  204. message.channel.awaitMessages(response => message.content, {
  205. max: 1,
  206. time: 300000000,
  207. errors: ['time'],
  208. })
  209. .then((collected) => {
  210.  
  211.  
  212.  
  213. if (collected.first().author != message.author) {
  214. message.channel.send("Message was not by the official message author!")
  215. } else {
  216. if (collected.first().content != "cancel") {
  217. console.log(args[1])
  218. if (args[1] == "true") {
  219. channel.send("@everyone, " + message.author + " made an announcement: \n\n" + collected.first().content)
  220. message.channel.send("Sent!")
  221. }
  222. if (args[1] == "false") {
  223. channel.send(message.author + " made an announcement: \n\n" + collected.first().content)
  224. message.channel.send("Sent!")
  225. }}
  226. }})
  227. .catch(function(){
  228. message.channel.send('No msg!');
  229. });
  230. })
  231.  
  232.  
  233.  
  234.  
  235. } else {
  236. message.channel.send("Incorrect arguments. Correct usage: -announce (ping everyone; put either true or false) (channel)")
  237. }
  238.  
  239. }}
  240.  
  241.  
  242.  
  243. if (command == "music") {
  244. if (args[0] == "play") {
  245. if (!message.member.voiceChannel) {
  246. message.channel.send("Join the music channel.. *facepalm*")
  247.  
  248. } else {
  249. if (args[1].length == 43) {
  250. var connection = message.member.voiceChannel;
  251.  
  252. var queuevar = {}
  253. queuevar.push(args[1])
  254. queue.set("queue", queuevar)
  255. play(connection,message)
  256.  
  257.  
  258.  
  259.  
  260.  
  261. } else{
  262. message.channel.send("Please input an youtube link.")
  263. }
  264. }
  265. }
  266. if (args[0] == "queue") {
  267.  
  268. if (!queue.get("queue")) {message.channel.send("No queue yet!"); return}
  269.  
  270. var msgaa = "The queue is:"
  271. var i;
  272. for (i = 0; i < queue.get("queue").length; i++) {
  273. msgaa = msgaa + "\n" + queue.get("queue")[i]
  274. }
  275. message.channel.send(msgaa)
  276. }
  277. }
  278.  
  279. }
  280.  
  281. });
  282. bot.login('NTE5NTM1MzY1MDA3MDgxNDcy.Dug2Sg.c5oYyJdNYGIQN8xz3IsHho_Z9yY');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement