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 = "-";
- const Enmap = require('enmap')
- const ffmpeg = require("ffmpeg")
- const ffmpegbinaries = require("ffmpeg-static")
- var roblox = require('roblox-js');
- var opus = require('opusscript')
- var ytdl = require('ytdl-core')
- var maximumRank = 14;
- var servers = {};
- var groupId = 4105355;
- var queue = new Enmap({name: "queue"});
- roblox.login({username: "Virtuals_Bot", password: "yeah not for you this is not the real password ofc"}).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
- });
- function play(connection2,message) {
- message.member.voiceChannel.join().then(connection => {
- var server = queue
- message.channel.send("Added to queue!")
- var stream = ytdl(server[0], {filter: 'audioonly'})
- server.shift()
- queue.set("queue",server)
- server.dispatcher = connection.playStream(stream)
- server.dispatcher.on("end",function(){
- if (server[0]) {
- message.channel.send("Now playing: " + server[0])
- play(connection,message)
- } else {
- message.channel.send("Queue over!")
- connection.disconnect()
- }
- })})
- }
- 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.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.content == "Please type your message!") {message.delete()}
- 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") {
- if (message.member.roles.has('519954873001967639')) {
- 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,username,true)
- .then(function(yes) {
- message.channel.send("Accepted!")
- }
- )
- })
- } else {
- message.channel.send("No username!")
- }}}
- if (command == "demote") {
- if (message.member.roles.has('519954873001967639')) {
- 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") {
- if (message.member.roles.has('519954873001967639')) {
- 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") {
- if (message.member.roles.has('519954873001967639')) {
- 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 == "announce") {
- if (message.member.roles.has('519954873001967639')) {
- if (args[0] && args[1]) {
- var channel = message.mentions.channels.first()
- message.channel.send("Please type the desired announcement. Say cancel to cancel.")
- .then(function(){
- message.channel.awaitMessages(response => message.content, {
- max: 1,
- time: 300000000,
- errors: ['time'],
- })
- .then((collected) => {
- if (collected.first().author != message.author) {
- message.channel.send("Message was not by the official message author!")
- } else {
- if (collected.first().content != "cancel") {
- console.log(args[1])
- if (args[1] == "true") {
- channel.send("@everyone, " + message.author + " made an announcement: \n\n" + collected.first().content)
- message.channel.send("Sent!")
- }
- if (args[1] == "false") {
- channel.send(message.author + " made an announcement: \n\n" + collected.first().content)
- message.channel.send("Sent!")
- }}
- }})
- .catch(function(){
- message.channel.send('No msg!');
- });
- })
- } else {
- message.channel.send("Incorrect arguments. Correct usage: -announce (ping everyone; put either true or false) (channel)")
- }
- }}
- if (command == "music") {
- if (args[0] == "play") {
- if (!message.member.voiceChannel) {
- message.channel.send("Join the music channel.. *facepalm*")
- } else {
- if (args[1].length == 43) {
- var connection = message.member.voiceChannel;
- var queuevar = {}
- queuevar.push(args[1])
- queue.set("queue", queuevar)
- play(connection,message)
- } else{
- message.channel.send("Please input an youtube link.")
- }
- }
- }
- if (args[0] == "queue") {
- if (!queue.get("queue")) {message.channel.send("No queue yet!"); return}
- var msgaa = "The queue is:"
- var i;
- for (i = 0; i < queue.get("queue").length; i++) {
- msgaa = msgaa + "\n" + queue.get("queue")[i]
- }
- message.channel.send(msgaa)
- }
- }
- }
- });
- bot.login('NTE5NTM1MzY1MDA3MDgxNDcy.Dug2Sg.c5oYyJdNYGIQN8xz3IsHho_Z9yY');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement