1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-12-22 21:13:18 +00:00
This commit is contained in:
MatteZ02 2019-10-11 11:48:50 +03:00
parent b3a83f3cf0
commit feea924d92
14 changed files with 38 additions and 43 deletions

View File

@ -9,7 +9,7 @@ module.exports = {
if (serverQueue) { if (serverQueue) {
if (message.author.id !== '360363051792203779') { 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 (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!'); if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to loop the queue!');
} }
} }

View File

@ -9,7 +9,7 @@ module.exports = {
if (serverQueue && serverQueue.playing === true) { 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 (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 (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!'); if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to pause the music!');
} }
} }

View File

@ -9,7 +9,7 @@ module.exports = {
if (serverQueue && !serverQueue.playing) { if (serverQueue && !serverQueue.playing) {
if (message.author.id !== '360363051792203779') { 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 (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!'); if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to resume the music!');
} }
} }

View File

@ -12,7 +12,7 @@ module.exports = {
if (message.author.id !== '360363051792203779') { if (message.author.id !== '360363051792203779') {
return message.channel.send(':x: This command is currently disabled!'); 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 (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!'); if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to seek the song!');
} }
} }

View File

@ -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 (!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[1] === 'prefix') {
if (!args[2]) return message.channel.send(`<:thonk:461691390972264449> Current prefix: \`${client.global.db.musix_guilds[message.guild.id].musix_prefix}\``); if (!args[2]) return message.channel.send(`<:thonk:461691390972264449> Current prefix: \`${client.global.db.guilds[message.guild.id].prefix}\``);
client.global.db.musix_guilds[message.guild.id].musix_prefix = args[2]; client.global.db.guilds[message.guild.id].prefix = args[2];
message.channel.send(`:white_check_mark: New prefix set to: \`${args[2]}\``); message.channel.send(`:white_check_mark: New prefix set to: \`${args[2]}\``);
} else if (args[1] === 'volume') { } 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 (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.'); 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]}\``); message.channel.send(`:white_check_mark: Default volume set to: \`${args[2]}\``);
} else if (args[1] === 'permissions') { } 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 (args[2] === 'true') {
if (client.global.db.musix_guilds[message.guild.id].permissions === false) { if (client.global.db.guilds[message.guild.id].permissions === false) {
client.global.db.musix_guilds[message.guild.id].permissions = true; client.global.db.guilds[message.guild.id].permissions = true;
message.channel.send(`:white_check_mark: Permissions requirement now set to: \`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 return message.channel.send(':x: That value is already `true`!');
} else if (args[2] === 'false') { } else if (args[2] === 'false') {
if (client.global.db.musix_guilds[message.guild.id].permissions === true) { if (client.global.db.guilds[message.guild.id].permissions === true) {
client.global.db.musix_guilds[message.guild.id].permissions = false; client.global.db.guilds[message.guild.id].permissions = false;
message.channel.send(`:white_check_mark: Permissions requirement now set to: \`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: That value is already `false`!');
} else return message.channel.send(':x: Please define a boolean! (true/false)'); } else return message.channel.send(':x: Please define a boolean! (true/false)');

View File

@ -9,7 +9,7 @@ module.exports = {
if (!serverQueue) return message.channel.send(':x: There is nothing playing that I could skip for you.'); if (!serverQueue) return message.channel.send(':x: There is nothing playing that I could skip for you.');
if (message.author.id !== '360363051792203779') { 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 (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!'); if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to skip songs!');
} }
} }

View File

@ -9,7 +9,7 @@ module.exports = {
if (!serverQueue) return message.channel.send(':x: There is nothing playing that I could stop for you.'); if (!serverQueue) return message.channel.send(':x: There is nothing playing that I could stop for you.');
if (message.author.id !== '360363051792203779') { 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 (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!'); if (!permissions.has('MANAGE_CHANNELS')) return message.channel.send(':x: You need the `MANAGE_CHANNELS` permission to stop the music!');
} }
} }

View File

@ -11,7 +11,7 @@ module.exports = {
if (!args[1]) return message.channel.send(`:loud_sound: The current volume is: **${serverQueue.volume}**`); if (!args[1]) return message.channel.send(`:loud_sound: The current volume is: **${serverQueue.volume}**`);
if (message.author.id !== '360363051792203779') { 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 (!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 (!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__.'); if (isNaN(args[1])) return message.channel.send(':x: I\'m sorry, But you need to enter a valid __number__.');

View File

@ -1,17 +1,15 @@
module.exports = { module.exports = {
name: 'guildcreate', name: 'guildcreate',
async execute(client, guild) { 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({ client.db.collection('guilds').doc(guild.id).set({
musix_prefix: '>', prefix: '>',
defaultVolume: 5, defaultVolume: 5,
permissions: true, permissions: false,
}); });
client.global.db.musix_guilds[guild.id] = { client.global.db.guilds[guild.id] = {
musix_prefix: ">", prefix: ">",
defaultVolume: 5, defaultVolume: 5,
permissions: true, permissions: false,
}; };
} }
} }

View File

@ -4,21 +4,21 @@ module.exports = {
if (message.author.bot || !message.guild) return; if (message.author.bot || !message.guild) return;
if (message.content.startsWith('->reset') && message.author.id === '360363051792203779') { if (message.content.startsWith('->reset') && message.author.id === '360363051792203779') {
client.guilds.forEach(guild => { client.guilds.forEach(guild => {
client.global.db.musix_guilds[guild.id] = { client.global.db.guilds[guild.id] = {
musix_prefix: ">", prefix: ">",
defaultVolume: 5, defaultVolume: 5,
permissions: true, permissions: false,
}; };
}); });
return message.channel.send(':white_check_mark: Reset all guild settings!') return message.channel.send(':white_check_mark: Reset all guild settings!')
} else if (message.content.startsWith('->resetguildsettings') && message.author.id === '360363051792203779') { } else if (message.content.startsWith('->resetguildsettings') && message.author.id === '360363051792203779') {
client.global.db.musix_guilds[message.guild.id] = { client.global.db.guilds[message.guild.id] = {
musix_prefix: ">", prefix: ">",
defaultVolume: 5, 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") { if (process.env.LOCALLYHOSTED === "true") {
prefix = "-"; prefix = "-";
if (message.author.id === "360363051792203779" || message.author.id === "384002606621655040") { 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] === '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.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; if (!args[0]) return;
let commandName = args[0].toLowerCase(); let commandName = args[0].toLowerCase();
if (commandName === `p`) { if (commandName === `p`) {

View File

@ -3,7 +3,7 @@ module.exports = {
async execute(client, dbl) { async execute(client, dbl) {
const remoteMusixGuildsData = await client.funcs.dbget('guilds', null, client); const remoteMusixGuildsData = await client.funcs.dbget('guilds', null, client);
remoteMusixGuildsData.forEach(guildData => { remoteMusixGuildsData.forEach(guildData => {
client.global.db.musix_guilds[guildData.id] = guildData.d; client.global.db.guilds[guildData.id] = guildData.d;
}); });
console.log('- DB Set -'); console.log('- DB Set -');
client.user.setActivity(`@musix help | 🎶`, { type: 'LISTENING' }); client.user.setActivity(`@musix help | 🎶`, { type: 'LISTENING' });
@ -11,9 +11,9 @@ module.exports = {
console.log('- Activated -'); console.log('- Activated -');
setInterval(async () => { setInterval(async () => {
client.guilds.forEach(guild => { client.guilds.forEach(guild => {
client.db.collection('guilds').doc(guild.id).set(client.global.db.musix_guilds[guild.id]); client.db.collection('guilds').doc(guild.id).set(client.global.db.guilds[guild.id]);
dbl.postStats(client.guilds.size);
}); });
dbl.postStats(client.guilds.size);
}, 1200000); }, 1200000);
} }
} }

View File

@ -6,9 +6,9 @@ module.exports = async function (video, message, voiceChannel, client, playlist
url: `https://www.youtube.com/watch?v=${video.id}` url: `https://www.youtube.com/watch?v=${video.id}`
} }
const serverQueue = client.queue.get(message.guild.id); const serverQueue = client.queue.get(message.guild.id);
if (client.global.db.musix_guilds[message.guild.id].defaultVolume === undefined) { if (client.global.db._guilds[message.guild.id].defaultVolume === undefined) {
client.global.db.musix_guilds[message.guild.id] = { client.global.db.guilds[message.guild.id] = {
musix_prefix: client.global.db.musix_guilds[message.guild.id].musix_prefix, prefix: client.global.db.guilds[message.guild.id].prefix,
defaultVolume: 5, defaultVolume: 5,
}; };
return message.channel.send(':x: `Error:` the default volume is undefined for this server. Please try again after a while.'); 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, voiceChannel: voiceChannel,
connection: null, connection: null,
songs: [], songs: [],
volume: client.global.db.musix_guilds[message.guild.id].defaultVolume, volume: client.global.db.guilds[message.guild.id].defaultVolume,
playing: true, playing: true,
looping: false looping: false
}; };

View File

@ -8,7 +8,7 @@ module.exports = async function (guild, song, client, message, seek) {
return; return;
} }
const dispatcher = serverQueue.connection 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 => { .on("end", reason => {
if (reason === "Stream is not generating quickly enough.") { if (reason === "Stream is not generating quickly enough.") {
console.log("Song ended"); console.log("Song ended");

View File

@ -1,4 +1,3 @@
console.log('- Starting FutoX & Musix -');
const Discord = require('discord.js'); const Discord = require('discord.js');
const client = new Discord.Client({ disableEveryone: true, disabledEvents: ['TYPING_START'] }); const client = new Discord.Client({ disableEveryone: true, disabledEvents: ['TYPING_START'] });
const DBL = require("dblapi.js"); const DBL = require("dblapi.js");
@ -19,8 +18,6 @@ client.db.FieldValue = require('firebase-admin').firestore.FieldValue;
client.global = { client.global = {
db: { db: {
guilds: {}, guilds: {},
musix_guilds: {},
specs: {},
}, },
}; };
@ -37,7 +34,7 @@ client.funcs.msToTime = require('./funcs/msToTime.js');
client.funcs.dbget = require('./funcs/dbget.js'); client.funcs.dbget = require('./funcs/dbget.js');
client.config = { client.config = {
token: process.env.MUSIX_TOKEN, token: process.env.MUSIX_REALTOKEN,
apikey: process.env.API_KEY, apikey: process.env.API_KEY,
prefix: '>', prefix: '>',
test: 'success', test: 'success',