From feea924d928f0ff05aeca61d2558fda6902c0e98 Mon Sep 17 00:00:00 2001 From: MatteZ02 <47610069+MatteZ02@users.noreply.github.com> Date: Fri, 11 Oct 2019 11:48:50 +0300 Subject: [PATCH] Update --- commands/loop.js | 2 +- commands/pause.js | 2 +- commands/resume.js | 2 +- commands/seek.js | 2 +- commands/settings.js | 18 +++++++++--------- commands/skip.js | 2 +- commands/stop.js | 2 +- commands/volume.js | 2 +- events/guildcreate.js | 12 +++++------- events/message.js | 16 ++++++++-------- events/ready.js | 6 +++--- funcs/handleVideo.js | 8 ++++---- funcs/play.js | 2 +- index.js | 5 +---- 14 files changed, 38 insertions(+), 43 deletions(-) diff --git a/commands/loop.js b/commands/loop.js index 16cca3f6..f5afd777 100644 --- a/commands/loop.js +++ b/commands/loop.js @@ -9,7 +9,7 @@ module.exports = { if (serverQueue) { if (message.author.id !== '360363051792203779') { if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voiceChannel as Musix to loop the queue!'); - if (client.global.db.musix_guilds[message.guild.id].permissions === true) { + if (client.global.db.guilds[message.guild.id].permissions === true) { if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to loop the queue!'); } } diff --git a/commands/pause.js b/commands/pause.js index 577e1274..635076f1 100644 --- a/commands/pause.js +++ b/commands/pause.js @@ -9,7 +9,7 @@ module.exports = { if (serverQueue && serverQueue.playing === true) { if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voiceChannel as Musix to pause the music!'); if (message.author.id !== '360363051792203779') { - if (client.global.db.musix_guilds[message.guild.id].permissions === true) { + if (client.global.db.guilds[message.guild.id].permissions === true) { if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to pause the music!'); } } diff --git a/commands/resume.js b/commands/resume.js index 2f5e58a4..7fe3e551 100644 --- a/commands/resume.js +++ b/commands/resume.js @@ -9,7 +9,7 @@ module.exports = { if (serverQueue && !serverQueue.playing) { if (message.author.id !== '360363051792203779') { if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voiceChannel as Musix to loop the queue!'); - if (client.global.db.musix_guilds[message.guild.id].permissions === true) { + if (client.global.db.guilds[message.guild.id].permissions === true) { if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to resume the music!'); } } diff --git a/commands/seek.js b/commands/seek.js index e9935485..6d196eca 100644 --- a/commands/seek.js +++ b/commands/seek.js @@ -12,7 +12,7 @@ module.exports = { if (message.author.id !== '360363051792203779') { return message.channel.send(':x: This command is currently disabled!'); if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voiceChannel as Musix to seek the song!'); - if (client.global.db.musix_guilds[message.guild.id].permissions === true) { + if (client.global.db.guilds[message.guild.id].permissions === true) { if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to seek the song!'); } } diff --git a/commands/settings.js b/commands/settings.js index 0c00edd5..2e860346 100644 --- a/commands/settings.js +++ b/commands/settings.js @@ -9,25 +9,25 @@ module.exports = { if (!permissions.has('MANAGE_GUILD')) return message.channel.send(':x: You need the `MANAGE_SERVER` permission to change the settings!'); } if (args[1] === 'prefix') { - if (!args[2]) return message.channel.send(`<:thonk:461691390972264449> Current prefix: \`${client.global.db.musix_guilds[message.guild.id].musix_prefix}\``); - client.global.db.musix_guilds[message.guild.id].musix_prefix = args[2]; + if (!args[2]) return message.channel.send(`<:thonk:461691390972264449> Current prefix: \`${client.global.db.guilds[message.guild.id].prefix}\``); + client.global.db.guilds[message.guild.id].prefix = args[2]; message.channel.send(`:white_check_mark: New prefix set to: \`${args[2]}\``); } else if (args[1] === 'volume') { - if (!args[2]) return message.channel.send(`:speaker: Current default volume is: \`${client.global.db.musix_guilds[message.guild.id].defaultVolume}\``); + if (!args[2]) return message.channel.send(`:speaker: Current default volume is: \`${client.global.db.guilds[message.guild.id].defaultVolume}\``); if (isNaN(args[2])) return message.channel.send(':x: I\'m sorry, But the default volume needs to be a valid __number__.'); if (args[2].length > 2) return message.channel.send(':x: The default volume must be below `100` for quality and safety resons.'); - client.global.db.musix_guilds[message.guild.id].defaultVolume = args[2]; + client.global.db.guilds[message.guild.id].defaultVolume = args[2]; message.channel.send(`:white_check_mark: Default volume set to: \`${args[2]}\``); } else if (args[1] === 'permissions') { - if (!args[2]) return message.channel.send(`🔒 Permission requirement: \`${client.global.db.musix_guilds[message.guild.id].permissions}\``); + if (!args[2]) return message.channel.send(`🔒 Permission requirement: \`${client.global.db.guilds[message.guild.id].permissions}\``); if (args[2] === 'true') { - if (client.global.db.musix_guilds[message.guild.id].permissions === false) { - client.global.db.musix_guilds[message.guild.id].permissions = true; + if (client.global.db.guilds[message.guild.id].permissions === false) { + client.global.db.guilds[message.guild.id].permissions = true; message.channel.send(`:white_check_mark: Permissions requirement now set to: \`true\``); } else return message.channel.send(':x: That value is already `true`!'); } else if (args[2] === 'false') { - if (client.global.db.musix_guilds[message.guild.id].permissions === true) { - client.global.db.musix_guilds[message.guild.id].permissions = false; + if (client.global.db.guilds[message.guild.id].permissions === true) { + client.global.db.guilds[message.guild.id].permissions = false; message.channel.send(`:white_check_mark: Permissions requirement now set to: \`false\``); } else return message.channel.send(':x: That value is already `false`!'); } else return message.channel.send(':x: Please define a boolean! (true/false)'); diff --git a/commands/skip.js b/commands/skip.js index 7009381b..e0e254d2 100644 --- a/commands/skip.js +++ b/commands/skip.js @@ -9,7 +9,7 @@ module.exports = { if (!serverQueue) return message.channel.send(':x: There is nothing playing that I could skip for you.'); if (message.author.id !== '360363051792203779') { if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voiceChannel as Musix to skip the song!'); - if (client.global.db.musix_guilds[message.guild.id].permissions === true) { + if (client.global.db.guilds[message.guild.id].permissions === true) { if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to skip songs!'); } } diff --git a/commands/stop.js b/commands/stop.js index 430c5787..5aa8ad8b 100644 --- a/commands/stop.js +++ b/commands/stop.js @@ -9,7 +9,7 @@ module.exports = { if (!serverQueue) return message.channel.send(':x: There is nothing playing that I could stop for you.'); if (message.author.id !== '360363051792203779') { if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voiceChannel as Musix to stop the music!'); - if (client.global.db.musix_guilds[message.guild.id].permissions === true) { + if (client.global.db.guilds[message.guild.id].permissions === true) { if (!permissions.has('MANAGE_CHANNELS')) return message.channel.send(':x: You need the `MANAGE_CHANNELS` permission to stop the music!'); } } diff --git a/commands/volume.js b/commands/volume.js index 7ca8bafa..94647fda 100644 --- a/commands/volume.js +++ b/commands/volume.js @@ -11,7 +11,7 @@ module.exports = { if (!args[1]) return message.channel.send(`:loud_sound: The current volume is: **${serverQueue.volume}**`); if (message.author.id !== '360363051792203779') { if (!voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in a voice channel to change the volume!'); - if (client.global.db.musix_guilds[message.guild.id].permissions === true) { + if (client.global.db.guilds[message.guild.id].permissions === true) { if (!permissions.has('MANAGE_CHANNELS')) return message.channel.send(':x: You need the `MANAGE_CHANNELS` permission to change the volume!'); } if (isNaN(args[1])) return message.channel.send(':x: I\'m sorry, But you need to enter a valid __number__.'); diff --git a/events/guildcreate.js b/events/guildcreate.js index 9b8cf68d..f4bf86dc 100644 --- a/events/guildcreate.js +++ b/events/guildcreate.js @@ -1,17 +1,15 @@ module.exports = { name: 'guildcreate', async execute(client, guild) { - let members = 0; - client.guilds.forEach(x => members += x.memberCount); 'users: ' + client.users.size + ', guildMembers: ' + members; client.db.collection('guilds').doc(guild.id).set({ - musix_prefix: '>', + prefix: '>', defaultVolume: 5, - permissions: true, + permissions: false, }); - client.global.db.musix_guilds[guild.id] = { - musix_prefix: ">", + client.global.db.guilds[guild.id] = { + prefix: ">", defaultVolume: 5, - permissions: true, + permissions: false, }; } } diff --git a/events/message.js b/events/message.js index cab9d08f..a537fbff 100644 --- a/events/message.js +++ b/events/message.js @@ -4,21 +4,21 @@ module.exports = { if (message.author.bot || !message.guild) return; if (message.content.startsWith('->reset') && message.author.id === '360363051792203779') { client.guilds.forEach(guild => { - client.global.db.musix_guilds[guild.id] = { - musix_prefix: ">", + client.global.db.guilds[guild.id] = { + prefix: ">", defaultVolume: 5, - permissions: true, + permissions: false, }; }); return message.channel.send(':white_check_mark: Reset all guild settings!') } else if (message.content.startsWith('->resetguildsettings') && message.author.id === '360363051792203779') { - client.global.db.musix_guilds[message.guild.id] = { - musix_prefix: ">", + client.global.db.guilds[message.guild.id] = { + prefix: ">", defaultVolume: 5, - permissions: true, + permissions: false, }; } - let prefix = client.global.db.musix_guilds[message.guild.id].musix_prefix; + let prefix = client.global.db.guilds[message.guild.id].prefix; if (process.env.LOCALLYHOSTED === "true") { prefix = "-"; if (message.author.id === "360363051792203779" || message.author.id === "384002606621655040") { @@ -30,7 +30,7 @@ module.exports = { if (message.mentions.users.first().id === '607266889537945605' && args[1] === 'help') return client.commands.get('help').execute(message, args, client, Discord, prefix, client); if (message.mentions.users.first().id === '607266889537945605' && args[1] === 'prefix') return message.channel.send(`My prefix here is: \`${prefix}\`.`); } - if (!message.content.startsWith(prefix)) return; + if (!message.content.startsWith(prefix) || message.guild.id !== '583597555095437312') return; if (!args[0]) return; let commandName = args[0].toLowerCase(); if (commandName === `p`) { diff --git a/events/ready.js b/events/ready.js index 4e39924d..ef2ca674 100644 --- a/events/ready.js +++ b/events/ready.js @@ -3,7 +3,7 @@ module.exports = { async execute(client, dbl) { const remoteMusixGuildsData = await client.funcs.dbget('guilds', null, client); remoteMusixGuildsData.forEach(guildData => { - client.global.db.musix_guilds[guildData.id] = guildData.d; + client.global.db.guilds[guildData.id] = guildData.d; }); console.log('- DB Set -'); client.user.setActivity(`@musix help | 🎶`, { type: 'LISTENING' }); @@ -11,9 +11,9 @@ module.exports = { console.log('- Activated -'); setInterval(async () => { client.guilds.forEach(guild => { - client.db.collection('guilds').doc(guild.id).set(client.global.db.musix_guilds[guild.id]); - dbl.postStats(client.guilds.size); + client.db.collection('guilds').doc(guild.id).set(client.global.db.guilds[guild.id]); }); + dbl.postStats(client.guilds.size); }, 1200000); } } \ No newline at end of file diff --git a/funcs/handleVideo.js b/funcs/handleVideo.js index b5ccf0e2..d9b8ef84 100644 --- a/funcs/handleVideo.js +++ b/funcs/handleVideo.js @@ -6,9 +6,9 @@ module.exports = async function (video, message, voiceChannel, client, playlist url: `https://www.youtube.com/watch?v=${video.id}` } const serverQueue = client.queue.get(message.guild.id); - if (client.global.db.musix_guilds[message.guild.id].defaultVolume === undefined) { - client.global.db.musix_guilds[message.guild.id] = { - musix_prefix: client.global.db.musix_guilds[message.guild.id].musix_prefix, + if (client.global.db._guilds[message.guild.id].defaultVolume === undefined) { + client.global.db.guilds[message.guild.id] = { + prefix: client.global.db.guilds[message.guild.id].prefix, defaultVolume: 5, }; return message.channel.send(':x: `Error:` the default volume is undefined for this server. Please try again after a while.'); @@ -19,7 +19,7 @@ module.exports = async function (video, message, voiceChannel, client, playlist voiceChannel: voiceChannel, connection: null, songs: [], - volume: client.global.db.musix_guilds[message.guild.id].defaultVolume, + volume: client.global.db.guilds[message.guild.id].defaultVolume, playing: true, looping: false }; diff --git a/funcs/play.js b/funcs/play.js index 38d5a4d1..ff683c55 100644 --- a/funcs/play.js +++ b/funcs/play.js @@ -8,7 +8,7 @@ module.exports = async function (guild, song, client, message, seek) { return; } const dispatcher = serverQueue.connection - .playStream(ytdl(song.url, { quality: `highestaudio`, filter: "audioonly" }), { seek: seek }) + .playStream(ytdl(song.url, { filter: "audio", highWaterMark: 1 << 25 }), { seek: seek, bitrate: 512, passes: 10, volume: 1 }) .on("end", reason => { if (reason === "Stream is not generating quickly enough.") { console.log("Song ended"); diff --git a/index.js b/index.js index 7840948b..c7b74ac7 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,3 @@ -console.log('- Starting FutoX & Musix -'); const Discord = require('discord.js'); const client = new Discord.Client({ disableEveryone: true, disabledEvents: ['TYPING_START'] }); const DBL = require("dblapi.js"); @@ -19,8 +18,6 @@ client.db.FieldValue = require('firebase-admin').firestore.FieldValue; client.global = { db: { guilds: {}, - musix_guilds: {}, - specs: {}, }, }; @@ -37,7 +34,7 @@ client.funcs.msToTime = require('./funcs/msToTime.js'); client.funcs.dbget = require('./funcs/dbget.js'); client.config = { - token: process.env.MUSIX_TOKEN, + token: process.env.MUSIX_REALTOKEN, apikey: process.env.API_KEY, prefix: '>', test: 'success',