1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-09-20 04:31:56 +00:00

Updated multiple things

This commit is contained in:
MatteZ02 2020-03-14 18:38:02 +02:00
parent ed1322cff6
commit 4a76582f76
31 changed files with 171 additions and 170 deletions

View File

@ -8,14 +8,14 @@ module.exports = {
permission: 'MANAGE_MESSAGES',
category: 'music',
execute(msg, args, client, Discord, prefix, command) {
const serverQueue = client.queue.get(msg.guild.id);
if (!args[1] && serverQueue) return msg.channel.send(`${client.messages.currentBass}**${serverQueue.bass}**`);
const queue = client.queue.get(msg.guild.id);
if (!args[1] && queue) return msg.channel.send(`${client.messages.currentBass}**${queue.bass}**`);
const bass = parseFloat(args[1]);
if (client.funcs.check(client, msg, command)) {
if (isNaN(bass)) return msg.channel.send(client.messages.validNumber);
if (bass > 100) return msg.channel.send(client.messages.maxBass);
if (bass < 0) return msg.channel.send(client.messages.positiveBass);
serverQueue.bass = bass;
queue.bass = bass;
let message;
message = client.messages.bassApplied.replace("%BASS%", bass);
return msg.channel.send(message);

View File

@ -6,7 +6,7 @@ module.exports = {
onlyDev: false,
permission: 'none',
category: 'info',
async execute(msg, args, client, Discord, prefix) {
async execute(msg, args, client, Discord, prefix, command) {
const embed = new Discord.MessageEmbed()
.setTitle(client.messages.bugTitle)
.setDescription(client.messages.bugDesc)

View File

@ -6,7 +6,7 @@ module.exports = {
onlyDev: true,
permission: 'dev',
category: 'info',
async execute(msg, args, client, Discord) {
async execute(msg, args, client, Discord, prefix, command) {
const cmduses = [];
client.commands.forEach((value, key) => {
cmduses.push([key, value.uses]);

View File

@ -6,12 +6,12 @@ module.exports = {
onlyDev: true,
permission: 'dev',
category: 'util',
async execute(msg, args, client, Discord, prefix) {
async execute(msg, args, client, Discord, prefix, command) {
const ytdl = require('ytdl-core');
const serverQueue = client.queue.get(msg.guild.id);
const queue = client.queue.get(msg.guild.id);
let data;
if (serverQueue) {
data = await Promise.resolve(ytdl.getInfo(serverQueue.songs[0].url));
if (queue) {
data = await Promise.resolve(ytdl.getInfo(queue.songs[0].url));
}
const input = msg.content.slice(prefix.length + 4);
let output;

View File

@ -6,7 +6,7 @@ module.exports = {
onlyDev: false,
permission: 'none',
category: 'info',
execute(msg, args, client, Discord, prefix) {
execute(msg, args, client, Discord, prefix, command) {
const embed = new Discord.MessageEmbed()
.setTitle(client.messages.inviteTitle)
.setURL(client.config.invite)

View File

@ -6,13 +6,13 @@ module.exports = {
onlyDev: true,
permission: 'none',
category: 'util',
async execute(msg, args, client, Discord, prefix) {
async execute(msg, args, client, Discord, prefix, command) {
try {
const serverQueue = client.queue.get(msg.guild.id);
const queue = client.queue.get(msg.guild.id);
const voiceChannel = msg.member.voice.channel;
const connection = await voiceChannel.join();
if (serverQueue) {
serverQueue.connection = connection;
if (queue) {
queue.connection = connection;
}
msg.channel.send(`${client.messages.joined} ${voiceChannel.name}!`);
} catch (error) {

View File

@ -7,13 +7,13 @@ module.exports = {
permission: 'MANAGE_MESSAGES',
category: 'music',
async execute(msg, args, client, Discord, prefix, command) {
const serverQueue = client.queue.get(msg.guild.id);
const queue = client.queue.get(msg.guild.id);
if (client.funcs.check(client, msg, command)) {
if (!serverQueue.looping) {
serverQueue.looping = true;
if (!queue.looping) {
queue.looping = true;
msg.channel.send(client.messages.looping);
} else {
serverQueue.looping = false;
queue.looping = false;
msg.channel.send(client.messages.noLooping);
}
}

View File

@ -7,15 +7,15 @@ module.exports = {
permission: 'MANAGE_MESSAGES',
category: 'music',
async execute(msg, args, client, Discord, prefix, command) {
const serverQueue = client.queue.get(msg.guild.id);
const queue = client.queue.get(msg.guild.id);
if (client.funcs.check(client, msg, command)) {
if (!serverQueue.songLooping) {
serverQueue.songLooping = true;
if (!queue.songLooping) {
queue.songLooping = true;
let message;
message = client.messages.loopingSong.replace("%TITLE%", serverQueue.songs[0].title);
message = client.messages.loopingSong.replace("%TITLE%", queue.songs[0].title);
msg.channel.send(message);
} else {
serverQueue.songLooping = false;
queue.songLooping = false;
msg.channel.send(message);
}
}

View File

@ -6,24 +6,24 @@ module.exports = {
onlyDev: false,
permission: 'none',
category: 'music',
async execute(msg, args, client, Discord, prefix) {
async execute(msg, args, client, Discord, prefix, command) {
const getThumb = require('video-thumbnail-url');
const ytdl = require('ytdl-core');
const serverQueue = client.queue.get(msg.guild.id);
if (!serverQueue) return msg.channel.send(client.messages.noServerQueue);
let data = await Promise.resolve(ytdl.getInfo(serverQueue.songs[0].url));
const queue = client.queue.get(msg.guild.id);
if (!queue) return msg.channel.send(client.messages.noServerQueue);
let data = await Promise.resolve(ytdl.getInfo(queue.songs[0].url));
let songtime = (data.length_seconds * 1000).toFixed(0);
serverQueue.time = serverQueue.connection.dispatcher.streamTime;
let completed = (serverQueue.time.toFixed(0));
queue.time = queue.connection.dispatcher.streamTime;
let completed = (queue.time.toFixed(0));
let barlength = 30;
let completedpercent = ((completed / songtime) * barlength).toFixed(0);
let array = []; for (let i = 0; i < completedpercent - 1; i++) { array.push('⎯'); } array.push('⭗'); for (let i = 0; i < barlength - completedpercent - 1; i++) { array.push('⎯'); }
const thumbnail = getThumb(serverQueue.songs[0].url);
const thumbnail = getThumb(queue.songs[0].url);
const embed = new Discord.MessageEmbed()
.setTitle(client.messages.nowPlaying)
.setDescription(`${client.messages.nowPlayingDesc} ${serverQueue.songs[0].title}\n${array.join('')} | \`${client.funcs.msToTime(completed, "hh:mm:ss")} / ${client.funcs.msToTime(songtime, "hh:mm:ss")}\``)
.setFooter(`Queued by ${serverQueue.songs[0].author.tag}`)
.setURL(serverQueue.songs[0].url)
.setDescription(`${client.messages.nowPlayingDesc} ${queue.songs[0].title}\n${array.join('')} | \`${client.funcs.msToTime(completed, "hh:mm:ss")} / ${client.funcs.msToTime(songtime, "hh:mm:ss")}\``)
.setFooter(`Queued by ${queue.songs[0].author.tag}`)
.setURL(queue.songs[0].url)
.setThumbnail(thumbnail._rejectionHandler0)
.setColor(client.config.embedColor)
return msg.channel.send(embed);

View File

@ -7,11 +7,11 @@ module.exports = {
permission: 'MANAGE_MESSAGES',
category: 'music',
execute(msg, args, client, Discord, prefix, command) {
const serverQueue = client.queue.get(msg.guild.id);
const queue = client.queue.get(msg.guild.id);
if (client.funcs.check(client, msg, command)) {
if (serverQueue.paused) return msg.channel.send(client.messages.alreadyPaused);
serverQueue.paused = true;
serverQueue.connection.dispatcher.pause(true);
if (queue.paused) return msg.channel.send(client.messages.alreadyPaused);
queue.paused = true;
queue.connection.dispatcher.pause(true);
return msg.channel.send(client.messages.paused);
}
}

View File

@ -8,25 +8,21 @@ module.exports = {
onlyDev: false,
permission: 'none',
category: 'music',
async execute(msg, args, client, Discord, prefix) {
async execute(msg, args, client, Discord, prefix, command) {
const youtube = new YouTube(client.config.api_key);
const searchString = args.slice(1).join(" ");
const url = args[1] ? args[1].replace(/<(.+)>/g, "$1") : "";
const serverQueue = client.queue.get(msg.guild.id);
const queue = client.queue.get(msg.guild.id);
const voiceChannel = msg.member.voice.channel;
if (!serverQueue) {
if (!queue) {
if (!msg.member.voice.channel) return msg.channel.send(client.messages.noVoiceChannel);
} else {
if (voiceChannel !== serverQueue.voiceChannel) return msg.channel.send(client.messages.wrongVoiceChannel);
if (voiceChannel !== queue.voiceChannel) return msg.channel.send(client.messages.wrongVoiceChannel);
}
if (!args[1]) return msg.channel.send(client.messages.noQuery);
const permissions = voiceChannel.permissionsFor(msg.client.user);
if (!permissions.has('CONNECT')) {
return msg.channel.send(client.messages.noPermsConnect);
}
if (!permissions.has('SPEAK')) {
return msg.channel.send(client.messages.noPermsSpeak);
}
if (voiceChannel.full) return msg.channel.send(client.messages.channelFull);
if (!voiceChannel.joinable) return msg.channel.send(client.messages.noPermsConnect);
if (!voiceChannel.speakable) return msg.channel.send(client.messages.noPermsSpeak);
if (url.match(/^https?:\/\/(www.youtube.com|youtube.com)\/playlist(.*)$/)) {
const lmsg = await msg.channel.send(client.messages.loadingSongs);
const playlist = await youtube.getPlaylist(url);

View File

@ -6,26 +6,23 @@ module.exports = {
onlyDev: false,
permission: 'none',
category: 'music',
async execute(msg, args, client, Discord, prefix) {
const serverQueue = client.queue.get(msg.guild.id);
if (!serverQueue) return msg.channel.send(client.messages.noServerQueue);
async execute(msg, args, client, Discord, prefix, command) {
const queue = client.queue.get(msg.guild.id);
if (!queue) return msg.channel.send(client.messages.noServerQueue);
const page = 1;
let queuesongs = serverQueue.songs.slice((page - 1) * 20 + 1, page * 20 + 1);
let queuesongs = queue.songs.slice((page - 1) * 20 + 1, page * 20 + 1);
let queuemessage = `${queuesongs.map(song => `**#** ${song.title}`).join('\n')}`
const hashs = queuemessage.split('**#**').length;
for (let i = 0; i < hashs; i++) {
queuemessage = queuemessage.replace('**#**', `**${i + 1}**`);
}
let message;
message = client.messages.queueDesc.replace("%SONG%", serverQueue.songs[0].title);
message = client.messages.queueDesc.replace("%SONG%", queue.songs[0].title);
const embed = new Discord.MessageEmbed()
.setTitle(client.messages.queueTitle)
.setDescription(`${message}\n${queuemessage}`)
.setFooter(`${serverQueue.songs.length} ${client.messages.queueFooter}`)
.setFooter(`${queue.songs.length} ${client.messages.queueFooter}`)
.setColor(client.config.embedColor)
/*if (serverQueue.songs.size > 20) {
embed.setFooter(`${serverQueue.songs.size - 20} ${client.messages.queueFooter}`)
}*/
return msg.channel.send(embed);
}
};

View File

@ -7,7 +7,7 @@ module.exports = {
permission: 'MANAGE_MESSAGES',
category: 'music',
execute(msg, args, client, Discord, prefix, command) {
const serverQueue = client.queue.get(msg.guild.id);
const queue = client.queue.get(msg.guild.id);
if (client.funcs.check(client, msg, command)) {
if (!args[1]) return msg.channel.send(client.messages.provideASong);
const pos = parseInt(args[1]);
@ -15,11 +15,11 @@ module.exports = {
if (pos < 1) return msg.channel.send(client.messages.noSongs);
let message1;
let message2;
message1 = client.messages.queueLength.replace("%LENGTH%", serverQueue.songs.length);
if (pos > serverQueue.songs.length) return msg.channel.send(message1);
message2 = client.messages.removed.replace("%SONG%", serverQueue.songs[pos].title);
message1 = client.messages.queueLength.replace("%LENGTH%", queue.songs.length);
if (pos > queue.songs.length) return msg.channel.send(message1);
message2 = client.messages.removed.replace("%SONG%", queue.songs[pos].title);
msg.channel.send(message2);
return serverQueue.songs.splice(pos, 1);
return queue.songs.splice(pos, 1);
}
}
};

View File

@ -7,11 +7,11 @@ module.exports = {
permission: 'MANAGE_MESSAGES',
category: 'music',
execute(msg, args, client, Discord, prefix, command) {
const serverQueue = client.queue.get(msg.guild.id);
const queue = client.queue.get(msg.guild.id);
if (client.funcs.check(client, msg, command)) {
if (!serverQueue.paused) return msg.channel.send(client.messages.notPaused);
serverQueue.paused = false;
serverQueue.connection.dispatcher.resume(true);
if (!queue.paused) return msg.channel.send(client.messages.notPaused);
queue.paused = false;
queue.connection.dispatcher.resume(true);
return msg.channel.send(client.messages.resumed);
}
}

View File

@ -9,25 +9,21 @@ module.exports = {
onlyDev: false,
permission: 'none',
category: 'music',
async execute(msg, args, client, Discord, prefix) {
async execute(msg, args, client, Discord, prefix, command) {
const youtube = new YouTube(client.config.api_key);
const searchString = args.slice(1).join(" ");
const url = args[1] ? args[1].replace(/<(.+)>/g, "$1") : "";
const serverQueue = client.queue.get(msg.guild.id);
const queue = client.queue.get(msg.guild.id);
const voiceChannel = msg.member.voice.channel;
if (!serverQueue) {
if (!queue) {
if (!msg.member.voice.channel) return msg.channel.send(client.messages.noVoiceChannel);
} else {
if (voiceChannel !== serverQueue.voiceChannel) return msg.channel.send(client.messages.wrongVoiceChannel);
if (voiceChannel !== queue.voiceChannel) return msg.channel.send(client.messages.wrongVoiceChannel);
}
if (!args[1]) return msg.channel.send(client.messages.noQuery);
const permissions = voiceChannel.permissionsFor(msg.client.user);
if (!permissions.has('CONNECT')) {
return msg.channel.send(client.messages.noPermsConnect);
}
if (!permissions.has('SPEAK')) {
return msg.channel.send(client.messages.noPermsSpeak);
}
if (voiceChannel.full) return msg.channel.send(client.messages.channelFull);
if (!voiceChannel.joinable) return msg.channel.send(client.messages.noPermsConnect);
if (!voiceChannel.speakable) return msg.channel.send(client.messages.noPermsSpeak);
if (url.match(/^https?:\/\/(www.youtube.com|youtube.com)\/playlist(.*)$/)) {
const lmsg = await msg.channel.send(client.messages.loadingSongs);
const playlist = await youtube.getPlaylist(url);

View File

@ -8,9 +8,9 @@ module.exports = {
category: 'music',
async execute(msg, args, client, Discord, prefix, command) {
const ytdl = require('ytdl-core');
const serverQueue = client.queue.get(msg.guild.id);
const queue = client.queue.get(msg.guild.id);
if (client.funcs.check(client, msg, command)) {
let data = await Promise.resolve(ytdl.getInfo(serverQueue.songs[0].url));
let data = await Promise.resolve(ytdl.getInfo(queue.songs[0].url));
if (!args[1]) return msg.channel.send(`${client.messages.correctUsage}\`${prefix}seek ${command.usage}\``);
let point = args[1];
const pos = parseInt(args[1]);
@ -21,9 +21,9 @@ module.exports = {
if (pos > data.length_seconds) return msg.channel.send(message);
point = pos;
}
serverQueue.connection.dispatcher.end();
serverQueue.endReason = "seek";
client.funcs.play(msg.guild, serverQueue.songs[0], client, msg, point, false);
queue.connection.dispatcher.end();
queue.endReason = "seek";
client.funcs.play(msg.guild, queue.songs[0], client, msg, point, false);
}
}
};

View File

@ -7,9 +7,9 @@ module.exports = {
permission: 'MANAGE_MESSAGES',
category: 'music',
execute(msg, args, client, Discord, prefix, command) {
const serverQueue = client.queue.get(msg.guild.id);
const queue = client.queue.get(msg.guild.id);
if (client.funcs.check(client, msg, command)) {
client.funcs.shuffle(serverQueue.songs);
client.funcs.shuffle(queue.songs);
msg.channel.send(client.messages.shuffled);
}
}

View File

@ -7,44 +7,44 @@ module.exports = {
permission: 'MANAGE_MESSAGES',
category: 'music',
execute(msg, args, client, Discord, prefix, command) {
const serverQueue = client.queue.get(msg.guild.id);
const queue = client.queue.get(msg.guild.id);
const permissions = msg.channel.permissionsFor(msg.author);
if (!serverQueue || !serverQueue.playing) return msg.channel.send(client.messages.noServerQueue);
if (!queue || !queue.playing) return msg.channel.send(client.messages.noServerQueue);
if (msg.author.id !== client.config.devId) {
if (msg.member.voice.channel !== serverQueue.voiceChannel) return msg.channel.send(client.messages.wrongVoiceChannel);
if (msg.member.voice.channel !== queue.voiceChannel) return msg.channel.send(client.messages.wrongVoiceChannel);
if (client.global.db.guilds[msg.guild.id].permissions) {
if (!msg.member.roles.cache.has(client.global.db.guilds[msg.guild.id].djrole) || !permissions.has(command.permission)) {
return vote(serverQueue, msg, client);
return vote(queue, msg, client);
} else {
return skipSong(serverQueue, msg, client);
return skipSong(queue, msg, client);
}
} else {
return skipSong(serverQueue, msg, client);
return skipSong(queue, msg, client);
}
} else {
return skipSong(serverQueue, msg, client);
return skipSong(queue, msg, client);
}
}
};
function skipSong(serverQueue, msg, client) {
function skipSong(queue, msg, client) {
msg.channel.send(client.messages.skipped);
serverQueue.endReason = "skip";
serverQueue.connection.dispatcher.end();
queue.endReason = "skip";
queue.connection.dispatcher.end();
};
function vote(serverQueue, msg, client) {
serverQueue.votesNeeded = Math.floor(serverQueue.voiceChannel.members.size / 2);
serverQueue.votesNeeded.toFixed();
if (serverQueue.voiceChannel.members.size > 2) {
if (serverQueue.voters.includes(msg.member.id)) return msg.channel.send(client.messages.alreadyVoted);
serverQueue.votes++;
serverQueue.voters.push(msg.member.id);
if (serverQueue.votes >= serverQueue.votesNeeded) {
serverQueue.voters = [];
serverQueue.votes = 0;
serverQueue.votesNeeded = null;
return skipSong(serverQueue, msg);
} else return msg.channel.send(`${client.messages.notEnoughVotes} ${serverQueue.votes} / ${serverQueue.votesNeeded}!`);
function vote(queue, msg, client) {
queue.votesNeeded = Math.floor(queue.voiceChannel.members.size / 2);
queue.votesNeeded.toFixed();
if (queue.voiceChannel.members.size > 2) {
if (queue.voters.includes(msg.member.id)) return msg.channel.send(client.messages.alreadyVoted);
queue.votes++;
queue.voters.push(msg.member.id);
if (queue.votes >= queue.votesNeeded) {
queue.voters = [];
queue.votes = 0;
queue.votesNeeded = null;
return skipSong(queue, msg);
} else return msg.channel.send(`${client.messages.notEnoughVotes} ${queue.votes} / ${queue.votesNeeded}!`);
} else {
return skipSong(serverQueue, msg);
return skipSong(queue, msg);
}
};

View File

@ -7,20 +7,20 @@ module.exports = {
permission: 'MANAGE_MESSAGES',
category: 'music',
async execute(msg, args, client, Discord, prefix, command) {
const serverQueue = client.queue.get(msg.guild.id);
const queue = client.queue.get(msg.guild.id);
if (client.funcs.check(client, msg, command)) {
if (!args[1]) return msg.channel.send(`${client.messages.correctUsage}\`${command.usage}\``);
const point = parseInt(args[1] - 1);
if (isNaN(point)) return msg.channel.send(client.messages.validNumber);
if (point > serverQueue.songs.size) return msg.channel.send(client.messages.noSongs);
if (point > queue.songs.size) return msg.channel.send(client.messages.noSongs);
if (point < 1) return msg.channel.send(client.messages.cantSkipToCurrent);
let i = 0;
while (i < point) {
i++;
serverQueue.songs.shift();
queue.songs.shift();
}
serverQueue.endReason = "skipto";
serverQueue.connection.dispatcher.end();
queue.endReason = "skipto";
queue.connection.dispatcher.end();
}
}
};

View File

@ -6,7 +6,7 @@ module.exports = {
onlyDev: false,
permission: 'none',
category: 'info',
execute(msg, args, client, Discord, prefix) {
execute(msg, args, client, Discord, prefix, command) {
const uptime = client.funcs.msToTime(client.uptime, "dd:hh:mm:ss");
msg.channel.send(client.messages.pinging).then(m => {
const latency = m.createdTimestamp - msg.createdTimestamp;

View File

@ -7,12 +7,12 @@ module.exports = {
permission: 'MANAGE_CHANNELS',
category: 'music',
execute(msg, args, client, Discord, prefix, command) {
const serverQueue = client.queue.get(msg.guild.id);
const queue = client.queue.get(msg.guild.id);
if (client.funcs.check(client, msg, command)) {
serverQueue.songs = [];
serverQueue.looping = false;
serverQueue.endReason = "stop";
serverQueue.connection.dispatcher.end();
queue.songs = [];
queue.looping = false;
queue.endReason = "stop";
queue.connection.dispatcher.end();
msg.channel.send(client.messages.stop)
}
}

View File

@ -8,15 +8,15 @@ module.exports = {
permission: 'MANAGE_MESSAGES',
category: 'music',
execute(msg, args, client, Discord, prefix, command) {
const serverQueue = client.queue.get(msg.guild.id);
if (!args[1] && serverQueue) return msg.channel.send(`${client.messages.currentVolume}**${serverQueue.volume}**`);
const queue = client.queue.get(msg.guild.id);
if (!args[1] && queue) return msg.channel.send(`${client.messages.currentVolume}**${queue.volume}**`);
const volume = parseFloat(args[1]);
if (client.funcs.check(client, msg, command)) {
if (isNaN(volume)) return msg.channel.send(client.messages.validNumber);
if (volume > 100) return msg.channel.send(client.messages.maxVolume);
if (volume < 0) return msg.channel.send(client.messages.positiveVolume);
serverQueue.volume = volume;
serverQueue.connection.dispatcher.setVolume(volume / 5);
queue.volume = volume;
queue.connection.dispatcher.setVolume(volume / 5);
return msg.channel.send(`${client.messages.setVolume}**${volume}**`);
}
}

View File

@ -0,0 +1,13 @@
module.exports = async function (client, error, guild) {
const queue = client.queue.get(guild.id);
console.error(error);
/*if (error = "Error: input stream: This video contains content from WMG, who has blocked it on copyright grounds.") {
queue.endReason = "skip";
queue.connection.dispatcher.end();
return queue.textChannel.send(client.messages.songBlockedWMG);
}*/
client.debug_channel.send(client.messages.dispatcherError + error);
queue.voiceChannel.leave();
client.queue.delete(guild.id);
return queue.textChannel.send(client.messages.errorDispatcher);
};

View File

@ -1,17 +1,17 @@
module.exports = async function (client, reason, guild) {
const serverQueue = client.queue.get(guild.id);
serverQueue.playing = false;
const queue = client.queue.get(guild.id);
queue.playing = false;
if (reason === "seek") {
return;
}
if (!serverQueue.songLooping) {
if (serverQueue.looping) {
serverQueue.songs.push(serverQueue.songs[0]);
if (!queue.songLooping) {
if (queue.looping) {
queue.songs.push(queue.songs[0]);
}
serverQueue.votes = 0;
serverQueue.voters = [];
serverQueue.songs.shift();
queue.votes = 0;
queue.voters = [];
queue.songs.shift();
}
client.funcs.play(guild, serverQueue.songs[0], client, 0, true);
client.funcs.play(guild, queue.songs[0], client, 0, true);
};

View File

@ -22,8 +22,8 @@ module.exports = {
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 msg.channel.send(client.messages.notAllowed);
//if (client.config.devMode && msg.member.id !== client.config.devId) return msg.channel.send(client.messages.devMode);
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, prefix, command);
}
}

View File

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

View File

@ -21,6 +21,7 @@ module.exports = class extends Client {
this.config = require('./config/config.js');
this.messages = require('./config/messages.js');
this.dispatcher.finish = require('../events/dispatcher/finish.js');
this.dispatcher.error = require('../events/dispatcher/error.js');
fs.readdirSync(path.join(__dirname, 'funcs')).forEach(filename => {
this.funcs[filename.slice(0, -3)] = require(`./funcs/${filename}`);

View File

@ -16,6 +16,7 @@ module.exports = {
bugTitle: "Found a bug with Musix?\nDM the core developer:",
cancellingVideoSelection: "<:redx:674263474704220182> Cancelling video selection",
cantSkipToCurrent: "<:redx:674263474704220182> You can't skip to the song currently playing!",
channelFull: "<:redx:674263474704220182> Your voice channel is full!",
cmdUsesFooter: "These statistics are from the current uptime.",
cmdUsesTitle: "Musix Command Usage During Current Uptime",
correctUsage: "<:redx:674263474704220182> correct usage: ",
@ -113,6 +114,7 @@ module.exports = {
shuffled: "<:shuffle:674685595980791871> Queue suffled!",
skipped: "<:skip:674685614221688832> Skipped the song!",
songAdded: "<:green_check_mark:674265384777416705> **%TITLE%** has been added to the queue!",
songBlockedWMG: "<:redx:674263474704220182> This song had been blocked by WMG (Warner Music Groud).\n<:skip:674685614221688832> Skipped to next song.",
songSelection: "__Song Selection__",
startPlaying: "<a:aNotes:674602408105476106> Start playing: ",
statusField1: ":signal_strength: Ping",

View File

@ -1,12 +1,12 @@
module.exports = function (client, msg, command) {
const serverQueue = client.queue.get(msg.guild.id);
const queue = client.queue.get(msg.guild.id);
const permissions = msg.channel.permissionsFor(msg.author);
if (!serverQueue || !serverQueue.playing) {
if (!queue || !queue.playing) {
msg.channel.send(client.messages.noServerQueue);
return false;
}
if (msg.author.id !== client.config.devId) {
if (msg.member.voice.channel !== serverQueue.voiceChannel) {
if (msg.member.voice.channel !== queue.voiceChannel) {
msg.channel.send(client.messages.wrongVoiceChannel);
return false;
}

View File

@ -7,10 +7,10 @@ module.exports = async function (video, msg, voiceChannel, client, playlist = fa
author: msg.author
}
const serverQueue = client.queue.get(msg.guild.id);
const queue = client.queue.get(msg.guild.id);
if (serverQueue) {
serverQueue.songs.push(song);
if (queue) {
queue.songs.push(song);
if (playlist) return;
let message;
message = client.messages.songAdded.replace("%TITLE%", song.title);

View File

@ -3,38 +3,34 @@ module.exports = async function (guild, song, client, seek, play) {
const ytdl = require('ytdl-core');
const getThumb = require('video-thumbnail-url');
const serverQueue = client.queue.get(guild.id);
const queue = client.queue.get(guild.id);
if (!song) {
serverQueue.voiceChannel.leave();
queue.voiceChannel.leave();
client.queue.delete(guild.id);
return;
}
const dispatcher = serverQueue.connection
.play(await ytdl(song.url, { filter: "audio", highWaterMark: 1 << 25, volume: false, begin: seek }), { seek: 0, bitrate: 1024, passes: 10, volume: 1, bassboost: serverQueue.bass })
const dispatcher = queue.connection
.play(await ytdl(song.url, { filter: "audio", highWaterMark: 1 << 25, volume: false, begin: seek }), { seek: 0, bitrate: 1024, passes: 10, volume: 1, bassboost: queue.bass })
.on("finish", () => {
client.dispatcher.finish(client, serverQueue.endReason, guild);
client.dispatcher.finish(client, queue.endReason, guild);
});
dispatcher.on('start', () => {
dispatcher.player.streamingData.pausedTime = 0;
});
dispatcher.on('error', error => {
console.error(error);
client.debug_channel.send(client.messages.dispatcherError + error);
serverQueue.voiceChannel.leave();
client.queue.delete(guild.id);
return serverQueue.textChannel.send(client.messages.errorDispatcher);
client.dispatcher.error(client, error, guild);
});
dispatcher.setVolume(serverQueue.volume / 10);
dispatcher.setVolume(queue.volume / 10);
if (client.global.db.guilds[guild.id].startPlaying || play) {
const data = await Promise.resolve(ytdl.getInfo(serverQueue.songs[0].url));
const data = await Promise.resolve(ytdl.getInfo(queue.songs[0].url));
const songtime = (data.length_seconds * 1000).toFixed(0);
const thumbnail = getThumb(serverQueue.songs[0].url);
const thumbnail = getThumb(queue.songs[0].url);
const embed = new Discord.MessageEmbed()
.setTitle(`${client.messages.startPlaying}**${song.title}**`)
.setDescription(`Song duration: \`${client.funcs.msToTime(songtime, "hh:mm:ss")}\``)
.setThumbnail(thumbnail._rejectionHandler0)
.setColor(client.config.embedColor)
serverQueue.textChannel.send(embed);
queue.textChannel.send(embed);
}
serverQueue.playing = true;
queue.playing = true;
}