2020-04-13 10:57:39 +00:00
|
|
|
module.exports = async function (
|
|
|
|
video,
|
|
|
|
msg,
|
|
|
|
voiceChannel,
|
|
|
|
client,
|
|
|
|
playlist = false
|
|
|
|
) {
|
|
|
|
const Discord = require("discord.js");
|
|
|
|
const song = {
|
|
|
|
title: Discord.Util.escapeMarkdown(video.title),
|
|
|
|
url: video.url,
|
|
|
|
author: msg.author,
|
|
|
|
};
|
2020-03-03 20:24:41 +00:00
|
|
|
|
2020-04-13 10:57:39 +00:00
|
|
|
const queue = client.queue.get(msg.guild.id);
|
2020-03-03 20:24:41 +00:00
|
|
|
|
2020-04-13 10:57:39 +00:00
|
|
|
if (queue) {
|
|
|
|
queue.songs.push(song);
|
2020-04-14 09:54:53 +00:00
|
|
|
queue.textChannel = msg.channel;
|
2020-04-13 10:57:39 +00:00
|
|
|
if (playlist) return;
|
|
|
|
let message;
|
|
|
|
message = client.messages.songAdded.replace("%TITLE%", song.title);
|
|
|
|
return msg.channel.send(message);
|
|
|
|
}
|
2020-02-05 20:02:53 +00:00
|
|
|
|
2020-04-13 11:30:20 +00:00
|
|
|
const construct = {
|
|
|
|
textChannel: null,
|
|
|
|
voiceChannel: null,
|
|
|
|
connection: null,
|
|
|
|
songs: [],
|
|
|
|
volume: null,
|
|
|
|
bass: null,
|
|
|
|
nigthCore: false,
|
|
|
|
playing: false,
|
|
|
|
paused: false,
|
|
|
|
looping: false,
|
|
|
|
songLooping: false,
|
|
|
|
votes: 0,
|
|
|
|
voters: [],
|
|
|
|
votesNeeded: null,
|
|
|
|
time: 0,
|
|
|
|
endReason: null,
|
|
|
|
};
|
2020-03-04 20:27:14 +00:00
|
|
|
|
2020-04-13 10:57:39 +00:00
|
|
|
construct.textChannel = msg.channel;
|
|
|
|
construct.voiceChannel = voiceChannel;
|
|
|
|
construct.volume = client.global.db.guilds[msg.guild.id].defaultVolume;
|
|
|
|
construct.bass = client.global.db.guilds[msg.guild.id].bass;
|
2020-03-03 20:24:41 +00:00
|
|
|
|
2020-04-13 10:57:39 +00:00
|
|
|
construct.songs.push(song);
|
2020-03-04 20:27:14 +00:00
|
|
|
|
2020-04-13 10:57:39 +00:00
|
|
|
client.queue.set(msg.guild.id, construct);
|
2020-02-05 20:02:53 +00:00
|
|
|
|
2020-04-13 10:57:39 +00:00
|
|
|
try {
|
|
|
|
const connection = await voiceChannel.join();
|
|
|
|
construct.connection = connection;
|
|
|
|
client.funcs.play(msg.guild, construct.songs[0], client, 0, true);
|
|
|
|
} catch (error) {
|
|
|
|
client.queue.delete(msg.guild.id);
|
|
|
|
client.users.cache
|
|
|
|
.get(client.config.devId)
|
|
|
|
.send(client.messages.errorConnecting + error);
|
|
|
|
return msg.channel.send(client.messages.error);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
};
|