mirror of
https://github.com/musix-org/musix-oss
synced 2024-11-10 08:10:18 +00:00
Updated multiple things
This commit is contained in:
parent
ed1322cff6
commit
4a76582f76
@ -8,14 +8,14 @@ module.exports = {
|
|||||||
permission: 'MANAGE_MESSAGES',
|
permission: 'MANAGE_MESSAGES',
|
||||||
category: 'music',
|
category: 'music',
|
||||||
execute(msg, args, client, Discord, prefix, command) {
|
execute(msg, args, client, Discord, prefix, command) {
|
||||||
const serverQueue = client.queue.get(msg.guild.id);
|
const queue = client.queue.get(msg.guild.id);
|
||||||
if (!args[1] && serverQueue) return msg.channel.send(`${client.messages.currentBass}**${serverQueue.bass}**`);
|
if (!args[1] && queue) return msg.channel.send(`${client.messages.currentBass}**${queue.bass}**`);
|
||||||
const bass = parseFloat(args[1]);
|
const bass = parseFloat(args[1]);
|
||||||
if (client.funcs.check(client, msg, command)) {
|
if (client.funcs.check(client, msg, command)) {
|
||||||
if (isNaN(bass)) return msg.channel.send(client.messages.validNumber);
|
if (isNaN(bass)) return msg.channel.send(client.messages.validNumber);
|
||||||
if (bass > 100) return msg.channel.send(client.messages.maxBass);
|
if (bass > 100) return msg.channel.send(client.messages.maxBass);
|
||||||
if (bass < 0) return msg.channel.send(client.messages.positiveBass);
|
if (bass < 0) return msg.channel.send(client.messages.positiveBass);
|
||||||
serverQueue.bass = bass;
|
queue.bass = bass;
|
||||||
let message;
|
let message;
|
||||||
message = client.messages.bassApplied.replace("%BASS%", bass);
|
message = client.messages.bassApplied.replace("%BASS%", bass);
|
||||||
return msg.channel.send(message);
|
return msg.channel.send(message);
|
||||||
|
@ -6,7 +6,7 @@ module.exports = {
|
|||||||
onlyDev: false,
|
onlyDev: false,
|
||||||
permission: 'none',
|
permission: 'none',
|
||||||
category: 'info',
|
category: 'info',
|
||||||
async execute(msg, args, client, Discord, prefix) {
|
async execute(msg, args, client, Discord, prefix, command) {
|
||||||
const embed = new Discord.MessageEmbed()
|
const embed = new Discord.MessageEmbed()
|
||||||
.setTitle(client.messages.bugTitle)
|
.setTitle(client.messages.bugTitle)
|
||||||
.setDescription(client.messages.bugDesc)
|
.setDescription(client.messages.bugDesc)
|
||||||
|
@ -6,7 +6,7 @@ module.exports = {
|
|||||||
onlyDev: true,
|
onlyDev: true,
|
||||||
permission: 'dev',
|
permission: 'dev',
|
||||||
category: 'info',
|
category: 'info',
|
||||||
async execute(msg, args, client, Discord) {
|
async execute(msg, args, client, Discord, prefix, command) {
|
||||||
const cmduses = [];
|
const cmduses = [];
|
||||||
client.commands.forEach((value, key) => {
|
client.commands.forEach((value, key) => {
|
||||||
cmduses.push([key, value.uses]);
|
cmduses.push([key, value.uses]);
|
||||||
|
@ -6,12 +6,12 @@ module.exports = {
|
|||||||
onlyDev: true,
|
onlyDev: true,
|
||||||
permission: 'dev',
|
permission: 'dev',
|
||||||
category: 'util',
|
category: 'util',
|
||||||
async execute(msg, args, client, Discord, prefix) {
|
async execute(msg, args, client, Discord, prefix, command) {
|
||||||
const ytdl = require('ytdl-core');
|
const ytdl = require('ytdl-core');
|
||||||
const serverQueue = client.queue.get(msg.guild.id);
|
const queue = client.queue.get(msg.guild.id);
|
||||||
let data;
|
let data;
|
||||||
if (serverQueue) {
|
if (queue) {
|
||||||
data = await Promise.resolve(ytdl.getInfo(serverQueue.songs[0].url));
|
data = await Promise.resolve(ytdl.getInfo(queue.songs[0].url));
|
||||||
}
|
}
|
||||||
const input = msg.content.slice(prefix.length + 4);
|
const input = msg.content.slice(prefix.length + 4);
|
||||||
let output;
|
let output;
|
||||||
|
@ -6,7 +6,7 @@ module.exports = {
|
|||||||
onlyDev: false,
|
onlyDev: false,
|
||||||
permission: 'none',
|
permission: 'none',
|
||||||
category: 'info',
|
category: 'info',
|
||||||
execute(msg, args, client, Discord, prefix) {
|
execute(msg, args, client, Discord, prefix, command) {
|
||||||
const embed = new Discord.MessageEmbed()
|
const embed = new Discord.MessageEmbed()
|
||||||
.setTitle(client.messages.inviteTitle)
|
.setTitle(client.messages.inviteTitle)
|
||||||
.setURL(client.config.invite)
|
.setURL(client.config.invite)
|
||||||
|
@ -6,13 +6,13 @@ module.exports = {
|
|||||||
onlyDev: true,
|
onlyDev: true,
|
||||||
permission: 'none',
|
permission: 'none',
|
||||||
category: 'util',
|
category: 'util',
|
||||||
async execute(msg, args, client, Discord, prefix) {
|
async execute(msg, args, client, Discord, prefix, command) {
|
||||||
try {
|
try {
|
||||||
const serverQueue = client.queue.get(msg.guild.id);
|
const queue = client.queue.get(msg.guild.id);
|
||||||
const voiceChannel = msg.member.voice.channel;
|
const voiceChannel = msg.member.voice.channel;
|
||||||
const connection = await voiceChannel.join();
|
const connection = await voiceChannel.join();
|
||||||
if (serverQueue) {
|
if (queue) {
|
||||||
serverQueue.connection = connection;
|
queue.connection = connection;
|
||||||
}
|
}
|
||||||
msg.channel.send(`${client.messages.joined} ${voiceChannel.name}!`);
|
msg.channel.send(`${client.messages.joined} ${voiceChannel.name}!`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -7,13 +7,13 @@ module.exports = {
|
|||||||
permission: 'MANAGE_MESSAGES',
|
permission: 'MANAGE_MESSAGES',
|
||||||
category: 'music',
|
category: 'music',
|
||||||
async execute(msg, args, client, Discord, prefix, command) {
|
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 (client.funcs.check(client, msg, command)) {
|
||||||
if (!serverQueue.looping) {
|
if (!queue.looping) {
|
||||||
serverQueue.looping = true;
|
queue.looping = true;
|
||||||
msg.channel.send(client.messages.looping);
|
msg.channel.send(client.messages.looping);
|
||||||
} else {
|
} else {
|
||||||
serverQueue.looping = false;
|
queue.looping = false;
|
||||||
msg.channel.send(client.messages.noLooping);
|
msg.channel.send(client.messages.noLooping);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,15 +7,15 @@ module.exports = {
|
|||||||
permission: 'MANAGE_MESSAGES',
|
permission: 'MANAGE_MESSAGES',
|
||||||
category: 'music',
|
category: 'music',
|
||||||
async execute(msg, args, client, Discord, prefix, command) {
|
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 (client.funcs.check(client, msg, command)) {
|
||||||
if (!serverQueue.songLooping) {
|
if (!queue.songLooping) {
|
||||||
serverQueue.songLooping = true;
|
queue.songLooping = true;
|
||||||
let message;
|
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);
|
msg.channel.send(message);
|
||||||
} else {
|
} else {
|
||||||
serverQueue.songLooping = false;
|
queue.songLooping = false;
|
||||||
msg.channel.send(message);
|
msg.channel.send(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,24 +6,24 @@ module.exports = {
|
|||||||
onlyDev: false,
|
onlyDev: false,
|
||||||
permission: 'none',
|
permission: 'none',
|
||||||
category: 'music',
|
category: 'music',
|
||||||
async execute(msg, args, client, Discord, prefix) {
|
async execute(msg, args, client, Discord, prefix, command) {
|
||||||
const getThumb = require('video-thumbnail-url');
|
const getThumb = require('video-thumbnail-url');
|
||||||
const ytdl = require('ytdl-core');
|
const ytdl = require('ytdl-core');
|
||||||
const serverQueue = client.queue.get(msg.guild.id);
|
const queue = client.queue.get(msg.guild.id);
|
||||||
if (!serverQueue) return msg.channel.send(client.messages.noServerQueue);
|
if (!queue) return msg.channel.send(client.messages.noServerQueue);
|
||||||
let data = await Promise.resolve(ytdl.getInfo(serverQueue.songs[0].url));
|
let data = await Promise.resolve(ytdl.getInfo(queue.songs[0].url));
|
||||||
let songtime = (data.length_seconds * 1000).toFixed(0);
|
let songtime = (data.length_seconds * 1000).toFixed(0);
|
||||||
serverQueue.time = serverQueue.connection.dispatcher.streamTime;
|
queue.time = queue.connection.dispatcher.streamTime;
|
||||||
let completed = (serverQueue.time.toFixed(0));
|
let completed = (queue.time.toFixed(0));
|
||||||
let barlength = 30;
|
let barlength = 30;
|
||||||
let completedpercent = ((completed / songtime) * barlength).toFixed(0);
|
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('⎯'); }
|
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()
|
const embed = new Discord.MessageEmbed()
|
||||||
.setTitle(client.messages.nowPlaying)
|
.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")}\``)
|
.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 ${serverQueue.songs[0].author.tag}`)
|
.setFooter(`Queued by ${queue.songs[0].author.tag}`)
|
||||||
.setURL(serverQueue.songs[0].url)
|
.setURL(queue.songs[0].url)
|
||||||
.setThumbnail(thumbnail._rejectionHandler0)
|
.setThumbnail(thumbnail._rejectionHandler0)
|
||||||
.setColor(client.config.embedColor)
|
.setColor(client.config.embedColor)
|
||||||
return msg.channel.send(embed);
|
return msg.channel.send(embed);
|
||||||
|
@ -7,11 +7,11 @@ module.exports = {
|
|||||||
permission: 'MANAGE_MESSAGES',
|
permission: 'MANAGE_MESSAGES',
|
||||||
category: 'music',
|
category: 'music',
|
||||||
execute(msg, args, client, Discord, prefix, command) {
|
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 (client.funcs.check(client, msg, command)) {
|
||||||
if (serverQueue.paused) return msg.channel.send(client.messages.alreadyPaused);
|
if (queue.paused) return msg.channel.send(client.messages.alreadyPaused);
|
||||||
serverQueue.paused = true;
|
queue.paused = true;
|
||||||
serverQueue.connection.dispatcher.pause(true);
|
queue.connection.dispatcher.pause(true);
|
||||||
return msg.channel.send(client.messages.paused);
|
return msg.channel.send(client.messages.paused);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,25 +8,21 @@ module.exports = {
|
|||||||
onlyDev: false,
|
onlyDev: false,
|
||||||
permission: 'none',
|
permission: 'none',
|
||||||
category: 'music',
|
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 youtube = new YouTube(client.config.api_key);
|
||||||
const searchString = args.slice(1).join(" ");
|
const searchString = args.slice(1).join(" ");
|
||||||
const url = args[1] ? args[1].replace(/<(.+)>/g, "$1") : "";
|
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;
|
const voiceChannel = msg.member.voice.channel;
|
||||||
if (!serverQueue) {
|
if (!queue) {
|
||||||
if (!msg.member.voice.channel) return msg.channel.send(client.messages.noVoiceChannel);
|
if (!msg.member.voice.channel) return msg.channel.send(client.messages.noVoiceChannel);
|
||||||
} else {
|
} 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);
|
if (!args[1]) return msg.channel.send(client.messages.noQuery);
|
||||||
const permissions = voiceChannel.permissionsFor(msg.client.user);
|
if (voiceChannel.full) return msg.channel.send(client.messages.channelFull);
|
||||||
if (!permissions.has('CONNECT')) {
|
if (!voiceChannel.joinable) return msg.channel.send(client.messages.noPermsConnect);
|
||||||
return msg.channel.send(client.messages.noPermsConnect);
|
if (!voiceChannel.speakable) return msg.channel.send(client.messages.noPermsSpeak);
|
||||||
}
|
|
||||||
if (!permissions.has('SPEAK')) {
|
|
||||||
return msg.channel.send(client.messages.noPermsSpeak);
|
|
||||||
}
|
|
||||||
if (url.match(/^https?:\/\/(www.youtube.com|youtube.com)\/playlist(.*)$/)) {
|
if (url.match(/^https?:\/\/(www.youtube.com|youtube.com)\/playlist(.*)$/)) {
|
||||||
const lmsg = await msg.channel.send(client.messages.loadingSongs);
|
const lmsg = await msg.channel.send(client.messages.loadingSongs);
|
||||||
const playlist = await youtube.getPlaylist(url);
|
const playlist = await youtube.getPlaylist(url);
|
||||||
|
@ -6,26 +6,23 @@ module.exports = {
|
|||||||
onlyDev: false,
|
onlyDev: false,
|
||||||
permission: 'none',
|
permission: 'none',
|
||||||
category: 'music',
|
category: 'music',
|
||||||
async execute(msg, args, client, Discord, prefix) {
|
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 (!serverQueue) return msg.channel.send(client.messages.noServerQueue);
|
if (!queue) return msg.channel.send(client.messages.noServerQueue);
|
||||||
const page = 1;
|
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')}`
|
let queuemessage = `${queuesongs.map(song => `**#** ${song.title}`).join('\n')}`
|
||||||
const hashs = queuemessage.split('**#**').length;
|
const hashs = queuemessage.split('**#**').length;
|
||||||
for (let i = 0; i < hashs; i++) {
|
for (let i = 0; i < hashs; i++) {
|
||||||
queuemessage = queuemessage.replace('**#**', `**${i + 1}**`);
|
queuemessage = queuemessage.replace('**#**', `**${i + 1}**`);
|
||||||
}
|
}
|
||||||
let message;
|
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()
|
const embed = new Discord.MessageEmbed()
|
||||||
.setTitle(client.messages.queueTitle)
|
.setTitle(client.messages.queueTitle)
|
||||||
.setDescription(`${message}\n${queuemessage}`)
|
.setDescription(`${message}\n${queuemessage}`)
|
||||||
.setFooter(`${serverQueue.songs.length} ${client.messages.queueFooter}`)
|
.setFooter(`${queue.songs.length} ${client.messages.queueFooter}`)
|
||||||
.setColor(client.config.embedColor)
|
.setColor(client.config.embedColor)
|
||||||
/*if (serverQueue.songs.size > 20) {
|
|
||||||
embed.setFooter(`${serverQueue.songs.size - 20} ${client.messages.queueFooter}`)
|
|
||||||
}*/
|
|
||||||
return msg.channel.send(embed);
|
return msg.channel.send(embed);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -7,7 +7,7 @@ module.exports = {
|
|||||||
permission: 'MANAGE_MESSAGES',
|
permission: 'MANAGE_MESSAGES',
|
||||||
category: 'music',
|
category: 'music',
|
||||||
execute(msg, args, client, Discord, prefix, command) {
|
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 (client.funcs.check(client, msg, command)) {
|
||||||
if (!args[1]) return msg.channel.send(client.messages.provideASong);
|
if (!args[1]) return msg.channel.send(client.messages.provideASong);
|
||||||
const pos = parseInt(args[1]);
|
const pos = parseInt(args[1]);
|
||||||
@ -15,11 +15,11 @@ module.exports = {
|
|||||||
if (pos < 1) return msg.channel.send(client.messages.noSongs);
|
if (pos < 1) return msg.channel.send(client.messages.noSongs);
|
||||||
let message1;
|
let message1;
|
||||||
let message2;
|
let message2;
|
||||||
message1 = client.messages.queueLength.replace("%LENGTH%", serverQueue.songs.length);
|
message1 = client.messages.queueLength.replace("%LENGTH%", queue.songs.length);
|
||||||
if (pos > serverQueue.songs.length) return msg.channel.send(message1);
|
if (pos > queue.songs.length) return msg.channel.send(message1);
|
||||||
message2 = client.messages.removed.replace("%SONG%", serverQueue.songs[pos].title);
|
message2 = client.messages.removed.replace("%SONG%", queue.songs[pos].title);
|
||||||
msg.channel.send(message2);
|
msg.channel.send(message2);
|
||||||
return serverQueue.songs.splice(pos, 1);
|
return queue.songs.splice(pos, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -7,11 +7,11 @@ module.exports = {
|
|||||||
permission: 'MANAGE_MESSAGES',
|
permission: 'MANAGE_MESSAGES',
|
||||||
category: 'music',
|
category: 'music',
|
||||||
execute(msg, args, client, Discord, prefix, command) {
|
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 (client.funcs.check(client, msg, command)) {
|
||||||
if (!serverQueue.paused) return msg.channel.send(client.messages.notPaused);
|
if (!queue.paused) return msg.channel.send(client.messages.notPaused);
|
||||||
serverQueue.paused = false;
|
queue.paused = false;
|
||||||
serverQueue.connection.dispatcher.resume(true);
|
queue.connection.dispatcher.resume(true);
|
||||||
return msg.channel.send(client.messages.resumed);
|
return msg.channel.send(client.messages.resumed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,25 +9,21 @@ module.exports = {
|
|||||||
onlyDev: false,
|
onlyDev: false,
|
||||||
permission: 'none',
|
permission: 'none',
|
||||||
category: 'music',
|
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 youtube = new YouTube(client.config.api_key);
|
||||||
const searchString = args.slice(1).join(" ");
|
const searchString = args.slice(1).join(" ");
|
||||||
const url = args[1] ? args[1].replace(/<(.+)>/g, "$1") : "";
|
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;
|
const voiceChannel = msg.member.voice.channel;
|
||||||
if (!serverQueue) {
|
if (!queue) {
|
||||||
if (!msg.member.voice.channel) return msg.channel.send(client.messages.noVoiceChannel);
|
if (!msg.member.voice.channel) return msg.channel.send(client.messages.noVoiceChannel);
|
||||||
} else {
|
} 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);
|
if (!args[1]) return msg.channel.send(client.messages.noQuery);
|
||||||
const permissions = voiceChannel.permissionsFor(msg.client.user);
|
if (voiceChannel.full) return msg.channel.send(client.messages.channelFull);
|
||||||
if (!permissions.has('CONNECT')) {
|
if (!voiceChannel.joinable) return msg.channel.send(client.messages.noPermsConnect);
|
||||||
return msg.channel.send(client.messages.noPermsConnect);
|
if (!voiceChannel.speakable) return msg.channel.send(client.messages.noPermsSpeak);
|
||||||
}
|
|
||||||
if (!permissions.has('SPEAK')) {
|
|
||||||
return msg.channel.send(client.messages.noPermsSpeak);
|
|
||||||
}
|
|
||||||
if (url.match(/^https?:\/\/(www.youtube.com|youtube.com)\/playlist(.*)$/)) {
|
if (url.match(/^https?:\/\/(www.youtube.com|youtube.com)\/playlist(.*)$/)) {
|
||||||
const lmsg = await msg.channel.send(client.messages.loadingSongs);
|
const lmsg = await msg.channel.send(client.messages.loadingSongs);
|
||||||
const playlist = await youtube.getPlaylist(url);
|
const playlist = await youtube.getPlaylist(url);
|
||||||
|
@ -8,9 +8,9 @@ module.exports = {
|
|||||||
category: 'music',
|
category: 'music',
|
||||||
async execute(msg, args, client, Discord, prefix, command) {
|
async execute(msg, args, client, Discord, prefix, command) {
|
||||||
const ytdl = require('ytdl-core');
|
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)) {
|
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}\``);
|
if (!args[1]) return msg.channel.send(`${client.messages.correctUsage}\`${prefix}seek ${command.usage}\``);
|
||||||
let point = args[1];
|
let point = args[1];
|
||||||
const pos = parseInt(args[1]);
|
const pos = parseInt(args[1]);
|
||||||
@ -21,9 +21,9 @@ module.exports = {
|
|||||||
if (pos > data.length_seconds) return msg.channel.send(message);
|
if (pos > data.length_seconds) return msg.channel.send(message);
|
||||||
point = pos;
|
point = pos;
|
||||||
}
|
}
|
||||||
serverQueue.connection.dispatcher.end();
|
queue.connection.dispatcher.end();
|
||||||
serverQueue.endReason = "seek";
|
queue.endReason = "seek";
|
||||||
client.funcs.play(msg.guild, serverQueue.songs[0], client, msg, point, false);
|
client.funcs.play(msg.guild, queue.songs[0], client, msg, point, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -7,9 +7,9 @@ module.exports = {
|
|||||||
permission: 'MANAGE_MESSAGES',
|
permission: 'MANAGE_MESSAGES',
|
||||||
category: 'music',
|
category: 'music',
|
||||||
execute(msg, args, client, Discord, prefix, command) {
|
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 (client.funcs.check(client, msg, command)) {
|
||||||
client.funcs.shuffle(serverQueue.songs);
|
client.funcs.shuffle(queue.songs);
|
||||||
msg.channel.send(client.messages.shuffled);
|
msg.channel.send(client.messages.shuffled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,44 +7,44 @@ module.exports = {
|
|||||||
permission: 'MANAGE_MESSAGES',
|
permission: 'MANAGE_MESSAGES',
|
||||||
category: 'music',
|
category: 'music',
|
||||||
execute(msg, args, client, Discord, prefix, command) {
|
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);
|
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.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 (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)) {
|
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 {
|
} else {
|
||||||
return skipSong(serverQueue, msg, client);
|
return skipSong(queue, msg, client);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return skipSong(serverQueue, msg, client);
|
return skipSong(queue, msg, client);
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
msg.channel.send(client.messages.skipped);
|
||||||
serverQueue.endReason = "skip";
|
queue.endReason = "skip";
|
||||||
serverQueue.connection.dispatcher.end();
|
queue.connection.dispatcher.end();
|
||||||
};
|
};
|
||||||
function vote(serverQueue, msg, client) {
|
function vote(queue, msg, client) {
|
||||||
serverQueue.votesNeeded = Math.floor(serverQueue.voiceChannel.members.size / 2);
|
queue.votesNeeded = Math.floor(queue.voiceChannel.members.size / 2);
|
||||||
serverQueue.votesNeeded.toFixed();
|
queue.votesNeeded.toFixed();
|
||||||
if (serverQueue.voiceChannel.members.size > 2) {
|
if (queue.voiceChannel.members.size > 2) {
|
||||||
if (serverQueue.voters.includes(msg.member.id)) return msg.channel.send(client.messages.alreadyVoted);
|
if (queue.voters.includes(msg.member.id)) return msg.channel.send(client.messages.alreadyVoted);
|
||||||
serverQueue.votes++;
|
queue.votes++;
|
||||||
serverQueue.voters.push(msg.member.id);
|
queue.voters.push(msg.member.id);
|
||||||
if (serverQueue.votes >= serverQueue.votesNeeded) {
|
if (queue.votes >= queue.votesNeeded) {
|
||||||
serverQueue.voters = [];
|
queue.voters = [];
|
||||||
serverQueue.votes = 0;
|
queue.votes = 0;
|
||||||
serverQueue.votesNeeded = null;
|
queue.votesNeeded = null;
|
||||||
return skipSong(serverQueue, msg);
|
return skipSong(queue, msg);
|
||||||
} else return msg.channel.send(`${client.messages.notEnoughVotes} ${serverQueue.votes} / ${serverQueue.votesNeeded}!`);
|
} else return msg.channel.send(`${client.messages.notEnoughVotes} ${queue.votes} / ${queue.votesNeeded}!`);
|
||||||
} else {
|
} else {
|
||||||
return skipSong(serverQueue, msg);
|
return skipSong(queue, msg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -7,20 +7,20 @@ module.exports = {
|
|||||||
permission: 'MANAGE_MESSAGES',
|
permission: 'MANAGE_MESSAGES',
|
||||||
category: 'music',
|
category: 'music',
|
||||||
async execute(msg, args, client, Discord, prefix, command) {
|
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 (client.funcs.check(client, msg, command)) {
|
||||||
if (!args[1]) return msg.channel.send(`${client.messages.correctUsage}\`${command.usage}\``);
|
if (!args[1]) return msg.channel.send(`${client.messages.correctUsage}\`${command.usage}\``);
|
||||||
const point = parseInt(args[1] - 1);
|
const point = parseInt(args[1] - 1);
|
||||||
if (isNaN(point)) return msg.channel.send(client.messages.validNumber);
|
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);
|
if (point < 1) return msg.channel.send(client.messages.cantSkipToCurrent);
|
||||||
let i = 0;
|
let i = 0;
|
||||||
while (i < point) {
|
while (i < point) {
|
||||||
i++;
|
i++;
|
||||||
serverQueue.songs.shift();
|
queue.songs.shift();
|
||||||
}
|
}
|
||||||
serverQueue.endReason = "skipto";
|
queue.endReason = "skipto";
|
||||||
serverQueue.connection.dispatcher.end();
|
queue.connection.dispatcher.end();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -6,7 +6,7 @@ module.exports = {
|
|||||||
onlyDev: false,
|
onlyDev: false,
|
||||||
permission: 'none',
|
permission: 'none',
|
||||||
category: 'info',
|
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");
|
const uptime = client.funcs.msToTime(client.uptime, "dd:hh:mm:ss");
|
||||||
msg.channel.send(client.messages.pinging).then(m => {
|
msg.channel.send(client.messages.pinging).then(m => {
|
||||||
const latency = m.createdTimestamp - msg.createdTimestamp;
|
const latency = m.createdTimestamp - msg.createdTimestamp;
|
||||||
|
@ -7,12 +7,12 @@ module.exports = {
|
|||||||
permission: 'MANAGE_CHANNELS',
|
permission: 'MANAGE_CHANNELS',
|
||||||
category: 'music',
|
category: 'music',
|
||||||
execute(msg, args, client, Discord, prefix, command) {
|
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 (client.funcs.check(client, msg, command)) {
|
||||||
serverQueue.songs = [];
|
queue.songs = [];
|
||||||
serverQueue.looping = false;
|
queue.looping = false;
|
||||||
serverQueue.endReason = "stop";
|
queue.endReason = "stop";
|
||||||
serverQueue.connection.dispatcher.end();
|
queue.connection.dispatcher.end();
|
||||||
msg.channel.send(client.messages.stop)
|
msg.channel.send(client.messages.stop)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,15 +8,15 @@ module.exports = {
|
|||||||
permission: 'MANAGE_MESSAGES',
|
permission: 'MANAGE_MESSAGES',
|
||||||
category: 'music',
|
category: 'music',
|
||||||
execute(msg, args, client, Discord, prefix, command) {
|
execute(msg, args, client, Discord, prefix, command) {
|
||||||
const serverQueue = client.queue.get(msg.guild.id);
|
const queue = client.queue.get(msg.guild.id);
|
||||||
if (!args[1] && serverQueue) return msg.channel.send(`${client.messages.currentVolume}**${serverQueue.volume}**`);
|
if (!args[1] && queue) return msg.channel.send(`${client.messages.currentVolume}**${queue.volume}**`);
|
||||||
const volume = parseFloat(args[1]);
|
const volume = parseFloat(args[1]);
|
||||||
if (client.funcs.check(client, msg, command)) {
|
if (client.funcs.check(client, msg, command)) {
|
||||||
if (isNaN(volume)) return msg.channel.send(client.messages.validNumber);
|
if (isNaN(volume)) return msg.channel.send(client.messages.validNumber);
|
||||||
if (volume > 100) return msg.channel.send(client.messages.maxVolume);
|
if (volume > 100) return msg.channel.send(client.messages.maxVolume);
|
||||||
if (volume < 0) return msg.channel.send(client.messages.positiveVolume);
|
if (volume < 0) return msg.channel.send(client.messages.positiveVolume);
|
||||||
serverQueue.volume = volume;
|
queue.volume = volume;
|
||||||
serverQueue.connection.dispatcher.setVolume(volume / 5);
|
queue.connection.dispatcher.setVolume(volume / 5);
|
||||||
return msg.channel.send(`${client.messages.setVolume}**${volume}**`);
|
return msg.channel.send(`${client.messages.setVolume}**${volume}**`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
13
events/dispatcher/error.js
Normal file
13
events/dispatcher/error.js
Normal 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);
|
||||||
|
};
|
@ -1,17 +1,17 @@
|
|||||||
module.exports = async function (client, reason, guild) {
|
module.exports = async function (client, reason, guild) {
|
||||||
const serverQueue = client.queue.get(guild.id);
|
const queue = client.queue.get(guild.id);
|
||||||
serverQueue.playing = false;
|
queue.playing = false;
|
||||||
if (reason === "seek") {
|
if (reason === "seek") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!serverQueue.songLooping) {
|
if (!queue.songLooping) {
|
||||||
if (serverQueue.looping) {
|
if (queue.looping) {
|
||||||
serverQueue.songs.push(serverQueue.songs[0]);
|
queue.songs.push(queue.songs[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
serverQueue.votes = 0;
|
queue.votes = 0;
|
||||||
serverQueue.voters = [];
|
queue.voters = [];
|
||||||
serverQueue.songs.shift();
|
queue.songs.shift();
|
||||||
}
|
}
|
||||||
client.funcs.play(guild, serverQueue.songs[0], client, 0, true);
|
client.funcs.play(guild, queue.songs[0], client, 0, true);
|
||||||
};
|
};
|
@ -22,8 +22,8 @@ module.exports = {
|
|||||||
if (commandName === "none") return;
|
if (commandName === "none") return;
|
||||||
const command = client.commands.get(commandName) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName)) || client.commandAliases.get(commandName);
|
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 && msg.content !== `${prefix}`) return;
|
||||||
if (command.onlyDev && msg.author.id !== client.config.devId) return msg.channel.send(client.messages.notAllowed);
|
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);
|
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);
|
client.funcs.exe(msg, args, client, Discord, prefix, command);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,30 +2,30 @@ module.exports = {
|
|||||||
name: 'voiceStateUpdate',
|
name: 'voiceStateUpdate',
|
||||||
async execute(client, oldState, newState) {
|
async execute(client, oldState, newState) {
|
||||||
let change = false;
|
let change = false;
|
||||||
const serverQueue = client.queue.get(newState.guild.id);
|
const queue = client.queue.get(newState.guild.id);
|
||||||
if (!serverQueue) return;
|
if (!queue) return;
|
||||||
if (newState.member.id === client.user.id && oldState.member.id === client.user.id) {
|
if (newState.member.id === client.user.id && oldState.member.id === client.user.id) {
|
||||||
if (newState.member.voice.channel === null) {
|
if (newState.member.voice.channel === null) {
|
||||||
serverQueue.songs = [];
|
queue.songs = [];
|
||||||
serverQueue.looping = false;
|
queue.looping = false;
|
||||||
serverQueue.endReason = "manual disconnect";
|
queue.endReason = "manual disconnect";
|
||||||
return client.queue.delete(newState.guild.id);
|
return client.queue.delete(newState.guild.id);
|
||||||
}
|
}
|
||||||
if (newState.member.voice.channel !== serverQueue.voiceChannel) {
|
if (newState.member.voice.channel !== queue.voiceChannel) {
|
||||||
change = true;
|
change = true;
|
||||||
serverQueue.voiceChannel = newState.member.voice.channel;
|
queue.voiceChannel = newState.member.voice.channel;
|
||||||
serverQueue.connection = newState.connection;
|
queue.connection = newState.connection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (oldState.channel === null) return;
|
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(() => {
|
setTimeout(() => {
|
||||||
if (!serverQueue) return;
|
if (!queue) return;
|
||||||
if (serverQueue.voiceChannel.members.size === 1) {
|
if (queue.voiceChannel.members.size === 1) {
|
||||||
serverQueue.songs = [];
|
queue.songs = [];
|
||||||
serverQueue.looping = false;
|
queue.looping = false;
|
||||||
serverQueue.endReason = "Timeout";
|
queue.endReason = "Timeout";
|
||||||
serverQueue.connection.dispatcher.end();
|
queue.connection.dispatcher.end();
|
||||||
}
|
}
|
||||||
}, 12000);
|
}, 12000);
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ module.exports = class extends Client {
|
|||||||
this.config = require('./config/config.js');
|
this.config = require('./config/config.js');
|
||||||
this.messages = require('./config/messages.js');
|
this.messages = require('./config/messages.js');
|
||||||
this.dispatcher.finish = require('../events/dispatcher/finish.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 => {
|
fs.readdirSync(path.join(__dirname, 'funcs')).forEach(filename => {
|
||||||
this.funcs[filename.slice(0, -3)] = require(`./funcs/${filename}`);
|
this.funcs[filename.slice(0, -3)] = require(`./funcs/${filename}`);
|
||||||
|
@ -16,6 +16,7 @@ module.exports = {
|
|||||||
bugTitle: "Found a bug with Musix?\nDM the core developer:",
|
bugTitle: "Found a bug with Musix?\nDM the core developer:",
|
||||||
cancellingVideoSelection: "<:redx:674263474704220182> Cancelling video selection",
|
cancellingVideoSelection: "<:redx:674263474704220182> Cancelling video selection",
|
||||||
cantSkipToCurrent: "<:redx:674263474704220182> You can't skip to the song currently playing!",
|
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.",
|
cmdUsesFooter: "These statistics are from the current uptime.",
|
||||||
cmdUsesTitle: "Musix Command Usage During Current Uptime",
|
cmdUsesTitle: "Musix Command Usage During Current Uptime",
|
||||||
correctUsage: "<:redx:674263474704220182> correct usage: ",
|
correctUsage: "<:redx:674263474704220182> correct usage: ",
|
||||||
@ -113,6 +114,7 @@ module.exports = {
|
|||||||
shuffled: "<:shuffle:674685595980791871> Queue suffled!",
|
shuffled: "<:shuffle:674685595980791871> Queue suffled!",
|
||||||
skipped: "<:skip:674685614221688832> Skipped the song!",
|
skipped: "<:skip:674685614221688832> Skipped the song!",
|
||||||
songAdded: "<:green_check_mark:674265384777416705> **%TITLE%** has been added to the queue!",
|
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__",
|
songSelection: "__Song Selection__",
|
||||||
startPlaying: "<a:aNotes:674602408105476106> Start playing: ",
|
startPlaying: "<a:aNotes:674602408105476106> Start playing: ",
|
||||||
statusField1: ":signal_strength: Ping",
|
statusField1: ":signal_strength: Ping",
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
module.exports = function (client, msg, command) {
|
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);
|
const permissions = msg.channel.permissionsFor(msg.author);
|
||||||
if (!serverQueue || !serverQueue.playing) {
|
if (!queue || !queue.playing) {
|
||||||
msg.channel.send(client.messages.noServerQueue);
|
msg.channel.send(client.messages.noServerQueue);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (msg.author.id !== client.config.devId) {
|
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);
|
msg.channel.send(client.messages.wrongVoiceChannel);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,10 @@ module.exports = async function (video, msg, voiceChannel, client, playlist = fa
|
|||||||
author: msg.author
|
author: msg.author
|
||||||
}
|
}
|
||||||
|
|
||||||
const serverQueue = client.queue.get(msg.guild.id);
|
const queue = client.queue.get(msg.guild.id);
|
||||||
|
|
||||||
if (serverQueue) {
|
if (queue) {
|
||||||
serverQueue.songs.push(song);
|
queue.songs.push(song);
|
||||||
if (playlist) return;
|
if (playlist) return;
|
||||||
let message;
|
let message;
|
||||||
message = client.messages.songAdded.replace("%TITLE%", song.title);
|
message = client.messages.songAdded.replace("%TITLE%", song.title);
|
||||||
|
@ -3,38 +3,34 @@ module.exports = async function (guild, song, client, seek, play) {
|
|||||||
const ytdl = require('ytdl-core');
|
const ytdl = require('ytdl-core');
|
||||||
const getThumb = require('video-thumbnail-url');
|
const getThumb = require('video-thumbnail-url');
|
||||||
|
|
||||||
const serverQueue = client.queue.get(guild.id);
|
const queue = client.queue.get(guild.id);
|
||||||
if (!song) {
|
if (!song) {
|
||||||
serverQueue.voiceChannel.leave();
|
queue.voiceChannel.leave();
|
||||||
client.queue.delete(guild.id);
|
client.queue.delete(guild.id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const dispatcher = serverQueue.connection
|
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: serverQueue.bass })
|
.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", () => {
|
.on("finish", () => {
|
||||||
client.dispatcher.finish(client, serverQueue.endReason, guild);
|
client.dispatcher.finish(client, queue.endReason, guild);
|
||||||
});
|
});
|
||||||
dispatcher.on('start', () => {
|
dispatcher.on('start', () => {
|
||||||
dispatcher.player.streamingData.pausedTime = 0;
|
dispatcher.player.streamingData.pausedTime = 0;
|
||||||
});
|
});
|
||||||
dispatcher.on('error', error => {
|
dispatcher.on('error', error => {
|
||||||
console.error(error);
|
client.dispatcher.error(client, error, guild);
|
||||||
client.debug_channel.send(client.messages.dispatcherError + error);
|
|
||||||
serverQueue.voiceChannel.leave();
|
|
||||||
client.queue.delete(guild.id);
|
|
||||||
return serverQueue.textChannel.send(client.messages.errorDispatcher);
|
|
||||||
});
|
});
|
||||||
dispatcher.setVolume(serverQueue.volume / 10);
|
dispatcher.setVolume(queue.volume / 10);
|
||||||
if (client.global.db.guilds[guild.id].startPlaying || play) {
|
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 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()
|
const embed = new Discord.MessageEmbed()
|
||||||
.setTitle(`${client.messages.startPlaying}**${song.title}**`)
|
.setTitle(`${client.messages.startPlaying}**${song.title}**`)
|
||||||
.setDescription(`Song duration: \`${client.funcs.msToTime(songtime, "hh:mm:ss")}\``)
|
.setDescription(`Song duration: \`${client.funcs.msToTime(songtime, "hh:mm:ss")}\``)
|
||||||
.setThumbnail(thumbnail._rejectionHandler0)
|
.setThumbnail(thumbnail._rejectionHandler0)
|
||||||
.setColor(client.config.embedColor)
|
.setColor(client.config.embedColor)
|
||||||
serverQueue.textChannel.send(embed);
|
queue.textChannel.send(embed);
|
||||||
}
|
}
|
||||||
serverQueue.playing = true;
|
queue.playing = true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user