Large update

This commit is contained in:
MatteZ02
2020-03-07 22:07:54 +02:00
parent 02e61cd9fa
commit 612a0b444d
15 changed files with 57 additions and 197 deletions

View File

@ -1,14 +1,11 @@
module.exports = {
name: 'ready',
async execute(client, Discord) {
const debugChannel = await client.channels.fetch(client.config.debug_channel);
client.debug_channel = debugChannel
if (client.config.devMode) {
console.log('dev mode');
}
client.user.setActivity(`@${client.user.username} help | 🎶`, { type: 'LISTENING' });
client.user.setStatus('online');
console.log('- Activated -');
setInterval(() => {
client.funcs.ffmpeg(client, Discord);
}, 7200000);
}
}

View File

@ -1,13 +1,32 @@
module.exports = {
name: 'voiceStateUpdate',
async execute(client, newMember) {
const serverQueue = client.radio.get(newMember.guild.id);
if (!serverQueue) return;
if (newMember === client.user) {
if (newMember.voice.channel !== serverQueue.voiceChannel) {
serverQueue.voiceChannel = newMember.voice.channel;
console.log(`Changed serverQueue voiceChannel since Musix was moved to a different channel!`);
async execute(client, oldState, newState) {
let change = false;
const radio = client.radio.get(newState.guild.id);
if (!radio) return;
if (newState.member.id === client.user.id && oldState.member.id === client.user.id) {
if (newState.member.voice.channel === null) {
radio.songs = [];
radio.looping = false;
radio.endReason = "manual disconnect";
return client.queue.delete(newState.guild.id);
}
if (newState.member.voice.channel !== radio.voiceChannel) {
change = true;
radio.voiceChannel = newState.member.voice.channel;
radio.connection = newState.connection;
}
}
if (oldState.channel === null) return;
if (oldState.channel.members.size === 1 && oldState.channel === radio.voiceChannel || change) {
setTimeout(() => {
if (!radio) return;
if (radio.voiceChannel.members.size === 1) {
radio.songs = [];
radio.looping = false;
radio.connection.dispatcher.end();
}
}, 12000);
}
}
}