1
0
mirror of https://github.com/musix-org/musix-oss synced 2025-06-17 10:46:01 +00:00

Update V3.0.4

This commit is contained in:
MatteZ02
2020-03-21 19:49:25 +02:00
parent b9f0eb3a96
commit 7e20f54362
63 changed files with 124 additions and 90 deletions

View File

@ -0,0 +1,23 @@
module.exports = {
name: 'guildcreate',
async execute(client, guild) {
client.db.collection('guilds').doc(guild.id).set({
prefix: client.config.prefix,
defaultVolume: client.config.defaultVolume,
permissions: client.config.permissions,
dj: client.config.dj,
djrole: client.config.djrole,
startPlaying: client.config.startPlaying,
bass: client.config.bass,
});
client.global.db.guilds[guild.id] = {
prefix: client.config.prefix,
defaultVolume: client.config.defaultVolume,
permissions: client.config.permissions,
dj: client.config.dj,
djrole: client.config.djrole,
startPlaying: client.config.startPlaying,
bass: client.config.bass,
};
}
}

View File

@ -0,0 +1,29 @@
module.exports = {
name: 'message',
async execute(client, msg, Discord) {
if (msg.author.bot || !msg.guild) return;
if (!client.global.db.guilds[msg.guild.id]) return;
let prefix = client.global.db.guilds[msg.guild.id].prefix;
if (client.config.devMode) prefix = client.config.devPrefix;
const args = msg.content.slice(prefix.length).split(' ');
if (msg.mentions.users.first()) {
if (msg.mentions.users.first().id === client.user.id) {
if (!args[1]) return;
if (args[1] === 'prefix') return msg.channel.send(`${client.messages.prefixHere}\`${prefix}\`.`);
if (args[1] === 'help') {
const command = client.commands.get("help");
return client.funcs.exe(msg, args, client, Discord, prefix, command);
}
}
}
if (!msg.content.startsWith(prefix)) return;
if (!args[0]) return;
const commandName = args[0].toLowerCase();
if (commandName === "none") return;
const command = client.commands.get(commandName) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName)) || client.commandAliases.get(commandName);
if (!command && msg.content !== `${prefix}`) return;
if (command.onlyDev && msg.author.id !== client.config.devId) return;
if (client.config.devMode && msg.member.id !== client.config.devId) return msg.channel.send(client.messages.devMode);
client.funcs.exe(msg, args, client, Discord, command);
}
}

View File

@ -0,0 +1,51 @@
const DBL = require("dblapi.js");
module.exports = {
name: 'ready',
async execute(client, Discord) {
const debugChannel = await client.channels.fetch(client.config.debug_channel);
client.debug_channel = debugChannel
const remoteMusixGuildsData = await client.funcs.dbget('guilds', null, client);
remoteMusixGuildsData.forEach(guildData => {
client.global.db.guilds[guildData.id] = guildData.d;
});
if (client.config.devMode) {
console.log('dev mode');
client.guilds.cache.forEach(guild => {
client.global.db.guilds[guild.id] = {
prefix: client.config.prefix,
defaultVolume: client.config.defaultVolume,
permissions: client.config.permissions,
dj: client.config.dj,
djrole: client.config.djrole,
startPlaying: client.config.startPlaying,
bass: client.config.bass,
};
});
}
console.log(`- DB Set - Shard: ${client.shard.ids} -`);
client.user.setActivity(`@${client.user.username} help | 🎶`, { type: 'LISTENING' });
client.user.setStatus('online');
const dbl = new DBL(client.config.dblKey, client);
if (client.config.dblApi && !client.config.devMode) {
dbl.on('posted', () => {
console.log('Server count posted!');
});
dbl.on('error', error => {
console.log('Error with DBL: ' + error);
});
dbl.postStats(client.guilds.size);
}
console.log(`- Activated - Shard: ${client.shard.ids} -`);
setInterval(() => {
client.funcs.checkDB(client);
}, 60000);
setInterval(async () => {
client.funcs.saveDB(client);
if (client.config.dblApi && !client.config.devMode) dbl.postStats(client.guilds.cache.size);
}, 1800000);
setInterval(() => {
client.funcs.ffmpeg(client, Discord);
}, 7200000);
}
}

View File

@ -0,0 +1,33 @@
module.exports = {
name: 'voiceStateUpdate',
async execute(client, oldState, newState) {
if (oldState.channel === null) return newState.setSelfDeaf(true);
let change = false;
const queue = client.queue.get(newState.guild.id);
if (!queue) return;
if (newState.member.id === client.user.id && oldState.member.id === client.user.id) {
if (newState.member.voice.channel === null) {
queue.songs = [];
queue.looping = false;
queue.endReason = "manual disconnect";
return client.queue.delete(newState.guild.id);
}
if (newState.member.voice.channel !== queue.voiceChannel) {
change = true;
queue.voiceChannel = newState.member.voice.channel;
queue.connection = newState.connection;
}
}
if (oldState.channel.members.size === 1 && oldState.channel === queue.voiceChannel || change) {
setTimeout(() => {
if (!queue) return;
if (queue.voiceChannel.members.size === 1) {
queue.songs = [];
queue.looping = false;
queue.endReason = "Timeout";
queue.connection.dispatcher.end();
}
}, 120000);
}
}
}