1
0
mirror of https://github.com/musix-org/musix-oss synced 2025-06-16 18:56:00 +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}**`);
}
}