1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-12-23 03:33:17 +00:00

big update

This commit is contained in:
MatteZ02 2019-12-05 15:17:15 +02:00
parent b83ee14cba
commit faa80e6749
19 changed files with 69 additions and 52 deletions

47
Struct/Client.js Normal file
View File

@ -0,0 +1,47 @@
const { Client, Collection } = require('discord.js');
const admin = require('firebase-admin');
const serviceAccount = require('./serviceAccount.json');
module.exports = class extends Client {
constructor() {
super({
disableEveryone: true,
disabledEvents: ['TYPING_START']
});
this.commands = new Collection();
this.commandAliases = new Collection();
this.playlistCmd = new Collection();
this.settingCmd = new Collection();
this.events = new Collection();
this.queue = new Map();
this.funcs = {};
this.funcs.handleVideo = require('./funcs/handleVideo.js');
this.funcs.play = require('./funcs/play.js');
this.funcs.msToTime = require('./funcs/msToTime.js');
this.funcs.dbget = require('./funcs/dbget.js');
this.funcs.exe = require('./funcs/exe.js');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
});
this.db = admin.firestore();
this.global = {
db: {
guilds: {},
playlists: {},
},
};
this.db.FieldValue = require('firebase-admin').firestore.FieldValue;
}
};

View File

@ -34,7 +34,7 @@ module.exports = async function (guild, song, client, message, seek, play) {
.setTitle(`:musical_note: Start playing: **${song.title}**`) .setTitle(`:musical_note: Start playing: **${song.title}**`)
.setDescription(`Song duration: \`${client.funcs.msToTime(songtime)}\``) .setDescription(`Song duration: \`${client.funcs.msToTime(songtime)}\``)
.setColor("#b50002") .setColor("#b50002")
serverQueue.playing = true;
serverQueue.textChannel.send(embed); serverQueue.textChannel.send(embed);
} }
serverQueue.playing = true;
} }

View File

@ -8,7 +8,7 @@ module.exports = {
const embed = new Discord.RichEmbed() const embed = new Discord.RichEmbed()
.setTitle(`Found a bug with ${client.user.username}?\nDM the core developer:`) .setTitle(`Found a bug with ${client.user.username}?\nDM the core developer:`)
.setDescription(`Matte#0002\nOr join the support server: https://discord.gg/rvHuJtB`) .setDescription(`Matte#0002\nOr join the support server: https://discord.gg/rvHuJtB`)
.setColor('#b50002'); .setColor(client.config.embedColor);
message.channel.send(embed); message.channel.send(embed);
}, },
}; };

View File

@ -22,7 +22,7 @@ module.exports = {
.setTitle('Musix Command Usage During Current Uptime') .setTitle('Musix Command Usage During Current Uptime')
.setDescription('```ml\n' + markdownrows.join('\n') + '\n```') .setDescription('```ml\n' + markdownrows.join('\n') + '\n```')
.setFooter('These statistics are from the current uptime.') .setFooter('These statistics are from the current uptime.')
.setColor('#b50002'); .setColor(client.config.embedColor);
msg.channel.send(embed); msg.channel.send(embed);
}, },
}; };

View File

@ -19,7 +19,7 @@ module.exports = {
} }
const embed = new Discord.RichEmbed() const embed = new Discord.RichEmbed()
.setTitle('Evaluation Command') .setTitle('Evaluation Command')
.setColor('#b50002') .setColor(client.config.embedColor)
.setDescription(`Input: \`\`\`js\n${input.replace(/; /g, ';').replace(/;/g, ';\n')}\n\`\`\`\nOutput: \`\`\`\n${output}\n\`\`\``); .setDescription(`Input: \`\`\`js\n${input.replace(/; /g, ';').replace(/;/g, ';\n')}\n\`\`\`\nOutput: \`\`\`\n${output}\n\`\`\``);
return message.channel.send(embed); return message.channel.send(embed);
}, },

View File

@ -6,7 +6,7 @@ module.exports = {
onlyDev: false, onlyDev: false,
execute(message, args, client, Discord, prefix) { execute(message, args, client, Discord, prefix) {
const embed = new Discord.RichEmbed() const embed = new Discord.RichEmbed()
.setTitle('Commands for Musix!') .setTitle(`Commands for ${client.user.username}!`)
.addField(`${prefix}play | ${prefix}p`, 'Play a song.', true) .addField(`${prefix}play | ${prefix}p`, 'Play a song.', true)
.addField(`${prefix}skip | ${prefix}s`, 'Skip a song.', true) .addField(`${prefix}skip | ${prefix}s`, 'Skip a song.', true)
.addField(`${prefix}queue | ${prefix}q`, 'Display the queue.', true) .addField(`${prefix}queue | ${prefix}q`, 'Display the queue.', true)
@ -22,8 +22,8 @@ module.exports = {
.addField(`${prefix}bug`, 'Report a bug.', true) .addField(`${prefix}bug`, 'Report a bug.', true)
.addField(`${prefix}settings`, 'Change the guild specific settings.', true) .addField(`${prefix}settings`, 'Change the guild specific settings.', true)
.addField(`${prefix}help`, 'Display the help.', true) .addField(`${prefix}help`, 'Display the help.', true)
.setAuthor(client.user.username, client.user.displayAvatarURL) .setAuthor(message.member.username, message.member.displayAvatarURL)
.setColor('#b50002') .setColor(client.config.embedColor)
return message.channel.send(embed); return message.channel.send(embed);
} }
}; };

View File

@ -6,9 +6,9 @@ module.exports = {
onlyDev: false, onlyDev: false,
execute(message, args, client, Discord, prefix) { execute(message, args, client, Discord, prefix) {
const embed = new Discord.RichEmbed() const embed = new Discord.RichEmbed()
.setTitle('Invite Musix to your Discord server!') .setTitle(`Invite ${client.user.username} to your Discord server!`)
.setURL('https://bit.ly/2YDrKgh') .setURL(client.config.invite)
.setColor('#b50002') .setColor(client.config.embedColor)
return message.channel.send(embed); return message.channel.send(embed);
} }
}; };

View File

@ -20,7 +20,7 @@ module.exports = {
.setDescription(`🎶**Now playing:** ${serverQueue.songs[0].title}\n${array.join('')} | \`${client.funcs.msToTime(completed)} / ${client.funcs.msToTime(songtime)}\``) .setDescription(`🎶**Now playing:** ${serverQueue.songs[0].title}\n${array.join('')} | \`${client.funcs.msToTime(completed)} / ${client.funcs.msToTime(songtime)}\``)
.setFooter(`Queued by ${serverQueue.songs[0].author.tag}`) .setFooter(`Queued by ${serverQueue.songs[0].author.tag}`)
.setURL(serverQueue.songs[0].url) .setURL(serverQueue.songs[0].url)
.setColor("#b50002") .setColor(client.config.embedColor)
return message.channel.send(embed); return message.channel.send(embed);
} }
}; };

View File

@ -47,7 +47,7 @@ module.exports = {
.setTitle("__Song Selection__") .setTitle("__Song Selection__")
.setDescription(`${videos.map(video2 => `**${++index}** ${he.decode(video2.title)} `).join('\n')}`) .setDescription(`${videos.map(video2 => `**${++index}** ${he.decode(video2.title)} `).join('\n')}`)
.setFooter("Please provide a number ranging from 1-10 to select one of the search results.") .setFooter("Please provide a number ranging from 1-10 to select one of the search results.")
.setColor("#b50002") .setColor(client.config.embedColor)
message.channel.send(embed); message.channel.send(embed);
try { try {
var response = await message.channel.awaitMessages(message2 => message2.content > 0 && message2.content < 11, { var response = await message.channel.awaitMessages(message2 => message2.content > 0 && message2.content < 11, {

View File

@ -18,7 +18,7 @@ module.exports = {
.addField('list', 'Display the playlist.', true) .addField('list', 'Display the playlist.', true)
.setFooter(`how to use: ${prefix}playlist <Option> <Optional option>`) .setFooter(`how to use: ${prefix}playlist <Option> <Optional option>`)
.setAuthor(client.user.username, client.user.displayAvatarURL) .setAuthor(client.user.username, client.user.displayAvatarURL)
.setColor('#b50002') .setColor(client.config.embedColor)
const permissions = message.channel.permissionsFor(message.author); const permissions = message.channel.permissionsFor(message.author);
if (message.author.id !== client.config.devId) { if (message.author.id !== client.config.devId) {
if (client.global.db.guilds[message.guild.id].dj) { if (client.global.db.guilds[message.guild.id].dj) {
@ -37,7 +37,7 @@ module.exports = {
const embed = new Discord.RichEmbed() const embed = new Discord.RichEmbed()
.setTitle(`Musix ${error.toString()}`) .setTitle(`Musix ${error.toString()}`)
.setDescription(error.stack.replace(/at /g, '**at **')) .setDescription(error.stack.replace(/at /g, '**at **'))
.setColor('#b50002'); .setColor(client.config.embedColor);
client.fetchUser(client.config.devId).then(user => user.send(embed)).catch(console.error); client.fetchUser(client.config.devId).then(user => user.send(embed)).catch(console.error);
client.channels.get(client.config.debug_channel).send(embed); client.channels.get(client.config.debug_channel).send(embed);
console.log(error); console.log(error);

View File

@ -25,14 +25,14 @@ module.exports = {
const embed = new Discord.RichEmbed() const embed = new Discord.RichEmbed()
.setTitle("__Song queue__") .setTitle("__Song queue__")
.setDescription(`**Now playing:** ${serverQueue.songs[0].title}🎶\n${pagetext}\n${queuemessage}`) .setDescription(`**Now playing:** ${serverQueue.songs[0].title}🎶\n${pagetext}\n${queuemessage}`)
.setColor("#b50002") .setColor(client.config.embedColor)
return message.channel.send(embed); return message.channel.send(embed);
} else { } else {
const embed = new Discord.RichEmbed() const embed = new Discord.RichEmbed()
.setTitle("__Song queue__") .setTitle("__Song queue__")
.setDescription(`**Now playing:** ${serverQueue.songs[0].title}🎶\n${pagetext}\n${queuemessage}`) .setDescription(`**Now playing:** ${serverQueue.songs[0].title}🎶\n${pagetext}\n${queuemessage}`)
.setFooter('🔁 Currently looping the queue!') .setFooter('🔁 Currently looping the queue!')
.setColor("#b50002") .setColor(client.config.embedColor)
return message.channel.send(embed); return message.channel.send(embed);
} }
} }

View File

@ -16,7 +16,7 @@ module.exports = {
.addField('songselection', 'Will i ask to select a song from the top 10 queries or start playing the first result instantly.') .addField('songselection', 'Will i ask to select a song from the top 10 queries or start playing the first result instantly.')
.setFooter(`how to use: ${prefix}settings <Setting name> <value>`) .setFooter(`how to use: ${prefix}settings <Setting name> <value>`)
.setAuthor(client.user.username, client.user.displayAvatarURL) .setAuthor(client.user.username, client.user.displayAvatarURL)
.setColor('#b50002') .setColor(client.embedColor)
const permissions = message.channel.permissionsFor(message.author); const permissions = message.channel.permissionsFor(message.author);
if (message.author.id !== client.config.devId) { if (message.author.id !== client.config.devId) {
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!');
@ -32,7 +32,7 @@ module.exports = {
const embed = new Discord.RichEmbed() const embed = new Discord.RichEmbed()
.setTitle(`Musix ${error.toString()}`) .setTitle(`Musix ${error.toString()}`)
.setDescription(error.stack.replace(/at /g, '**at **')) .setDescription(error.stack.replace(/at /g, '**at **'))
.setColor('#b50002'); .setColor(client.config.embedColor);
client.fetchUser(client.config.devId).then(user => user.send(embed)).catch(console.error); client.fetchUser(client.config.devId).then(user => user.send(embed)).catch(console.error);
client.channels.get(client.config.debug_channel).send(embed); client.channels.get(client.config.debug_channel).send(embed);
} }

View File

@ -25,7 +25,7 @@ module.exports = {
.addField(`:play_pause: Currently playing music on`, `${client.voiceConnections.size} guild(s)`, true) .addField(`:play_pause: Currently playing music on`, `${client.voiceConnections.size} guild(s)`, true)
.addField(`💿 Operating system`, process.platform, true) .addField(`💿 Operating system`, process.platform, true)
.setAuthor(client.user.username, client.user.displayAvatarURL) .setAuthor(client.user.username, client.user.displayAvatarURL)
.setColor('#b50002') .setColor(client.config.embedColor)
return message.channel.send(embed); return message.channel.send(embed);
} }
}; };

View File

@ -1,41 +1,11 @@
const Discord = require('discord.js'); const Discord = require('discord.js');
const client = new Discord.Client({ disableEveryone: true, disabledEvents: ['TYPING_START'] }); const MusicClient = require('./Struct/Client');
const client = new MusicClient({});
const DBL = require("dblapi.js"); const DBL = require("dblapi.js");
const dbl = new DBL(process.env.DBLTOKEN, client); const dbl = new DBL(process.env.DBLTOKEN, client);
const fs = require('fs'); const fs = require('fs');
const dotenv = require('dotenv');
const firebase = require('firebase/app');
const admin = require('firebase-admin');
const serviceAccount = require('./serviceAccount.json');
require('dotenv/config'); require('dotenv/config');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
});
client.db = admin.firestore();
client.db.FieldValue = require('firebase-admin').firestore.FieldValue;
client.global = {
db: {
guilds: {},
playlists: {},
},
};
client.commands = new Discord.Collection();
client.commandAliases = new Discord.Collection();
client.playlistCmd = new Discord.Collection();
client.settingCmd = new Discord.Collection();
client.events = new Discord.Collection();
client.queue = new Map();
client.funcs = {};
client.funcs.handleVideo = require('./funcs/handleVideo.js');
client.funcs.play = require('./funcs/play.js');
client.funcs.msToTime = require('./funcs/msToTime.js');
client.funcs.dbget = require('./funcs/dbget.js');
client.funcs.exe = require('./funcs/exe.js');
client.config = require('./config/config.js'); client.config = require('./config/config.js');
const commandFiles = fs.readdirSync('./commands/').filter(f => f.endsWith('.js')); const commandFiles = fs.readdirSync('./commands/').filter(f => f.endsWith('.js'));
@ -85,5 +55,4 @@ client.on('guildCreate', async (guild) => {
dbl.on('error', error => { dbl.on('error', error => {
console.log(`Error with DBL! ${error}`); console.log(`Error with DBL! ${error}`);
}) })
client.login(client.config.token).catch(err => { console.log('- Failed To Login -> ' + err); }); client.login(client.config.token).catch(err => { console.log('- Failed To Login -> ' + err); });

View File

@ -18,6 +18,7 @@
"dblapi.js": "^2.3.0", "dblapi.js": "^2.3.0",
"discord.js": "^11.5.1", "discord.js": "^11.5.1",
"dotenv": "^8.2.0", "dotenv": "^8.2.0",
"ffmpeg-binaries": "^4.0.0",
"firebase": "^6.6.2", "firebase": "^6.6.2",
"firebase-admin": "^8.6.1", "firebase-admin": "^8.6.1",
"fs": "0.0.1-security", "fs": "0.0.1-security",