1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-12-22 18:03:17 +00:00
This commit is contained in:
MatteZ02 2020-06-30 21:08:18 +03:00
parent 2353262322
commit 3842f30bff
9 changed files with 38 additions and 26 deletions

View File

@ -53,7 +53,6 @@ module.exports = {
client.messages.settingsAutoPlayDesc,
true
)
.addField()
.setFooter(footer)
.setAuthor(client.user.username, client.user.displayAvatarURL)
.setColor(client.config.embedColor);
@ -81,4 +80,4 @@ module.exports = {
return msg.channel.send(embed);
}
},
};
};

View File

@ -11,7 +11,7 @@ module.exports = {
bass: client.config.bass,
blacklist: [],
premium: false,
playSimilar: client.config.playSimilar,
autoPlay: client.config.autoPlay,
};
msg.channel.send(client.messages.reset);
}

View File

@ -11,7 +11,7 @@ module.exports = {
bass: client.config.bass,
blacklist: [],
premium: false,
playSimilar: client.config.playSimilar,
autoPlay: client.config.autoPlay,
});
client.global.db.guilds[guild.id] = {
prefix: client.config.prefix,
@ -23,7 +23,7 @@ module.exports = {
bass: client.config.bass,
blacklist: [],
premium: false,
playSimilar: client.config.playSimilar,
autoPlay: client.config.autoPlay,
};
},
};

View File

@ -21,7 +21,7 @@ module.exports = {
bass: client.config.bass,
blacklist: [],
premium: true,
playSimilar: client.config.playSimilar,
autoPlay: client.config.autoPlay,
};
});
}

View File

@ -19,11 +19,20 @@ module.exports = {
queue.votes = 0;
queue.voters = [];
if (queue.endReason !== "replay") {
if (queue.endReason === "previous") queue.songs.unshift(queue.prevSongs.pop())
if (queue.endReason !== "previous") queue.prevSongs.push(queue.songs.shift());
if (client.global.db.guilds[guild.id].playSimilar && !queue.songs[0] && queue.endReason !== "stop") {
const prevSongs = queue.prevSongs.filter(song => song.type == "spotify");
if (prevSongs.length >= 0) return findSimilar(client, queue, prevSongs, guild);
if (queue.endReason === "previous")
queue.songs.unshift(queue.prevSongs.pop());
if (queue.endReason !== "previous")
queue.prevSongs.push(queue.songs.shift());
if (
client.global.db.guilds[guild.id].autoPlay &&
!queue.songs[0] &&
queue.endReason !== "stop"
) {
const prevSongs = queue.prevSongs.filter(
(song) => song.type == "spotify"
);
if (prevSongs.length >= 0)
return findSimilar(client, queue, prevSongs, guild);
}
}
}
@ -33,8 +42,8 @@ module.exports = {
function findSimilar(client, queue, prevSongs, guild) {
let retries = 0;
const query = prevSongs[Math.floor(Math.random() * Math.floor(prevSongs.length))];
if (!query) return client.funcs.play(guild, queue.songs[0], client, 0, true);
const query =
prevSongs[Math.floor(Math.random() * Math.floor(prevSongs.length))];
similarSongs.find({
title: query.track.name,
artist: query.track.artists[0].name,
@ -44,16 +53,21 @@ function findSimilar(client, queue, prevSongs, guild) {
youtubeAPIKey: client.config.api_key,
},
async function (err, songs) {
if (err) return queue.textChannel.send(err.message);
if (err) {
console.log(err.message);
return queue.textChannel.send(client.messages.error);
}
if (songs[0]) {
const random = Math.floor(Math.random() * Math.floor(songs.length))
const songInfo = await ytdl.getInfo(`https://www.youtube.com/watch?v=${songs[random].youtubeId}`);
const random = Math.floor(Math.random() * Math.floor(songs.length));
const songInfo = await ytdl.getInfo(
`https://www.youtube.com/watch?v=${songs[random].youtubeId}`
);
queue.songs.push({
title: Discord.Util.escapeMarkdown(songInfo.videoDetails.title),
url: `https://www.youtube.com/watch?v=${songs[random].youtubeId}`,
author: {},
type: "ytdl",
info: songInfo.videoDetails
info: songInfo.videoDetails,
});
client.funcs.play(guild, queue.songs[0], client, 0, true);
} else {

View File

@ -22,8 +22,7 @@ module.exports = {
secondary_test_channel: "570531724002328577",
devId: "360363051792203779",
embedColor: "#b50002",
invite:
"https://discordapp.com/oauth2/authorize?client_id=607266889537945605&permissions=3427328&scope=bot",
invite: "https://discordapp.com/oauth2/authorize?client_id=607266889537945605&permissions=3427328&scope=bot",
supportServer: "https://discord.gg/rvHuJtB",
devMode: false,
api: false,
@ -41,7 +40,7 @@ module.exports = {
djrole: null,
startPlaying: true,
bass: 1,
playSimilar: false,
autoPlay: false,
};
module.exports.streamConfig = {
@ -100,4 +99,4 @@ module.exports.emojis = {
stop: "<:stop:674685626108477519> ",
stopWatch: ":stopwatch: ",
volumeHigh: "<:volumehigh:674685637626167307> ",
};
};

View File

@ -5,7 +5,7 @@ const {
module.exports = {
emojis: emojis,
albumAdded: emojis.green_check_mark +
"Album: **%TITLE%** has been added to the queue!",
"Album has been added to the queue!",
alreadyPaused: emojis.redx + "The music is already paused!",
alreadyVoted: emojis.redx + "You have already voted to skip!",
announceSongs: emojis.megaPhone + "Current setting:",

View File

@ -11,7 +11,7 @@ module.exports = async function (client) {
bass: client.config.bass,
blacklist: [],
premium: false,
playSimilar: client.config.playSimilar,
autoPlay: client.config.autoPlay,
});
client.global.db.guilds[guild.id] = {
prefix: client.config.prefix,
@ -23,7 +23,7 @@ module.exports = async function (client) {
bass: client.config.bass,
blacklist: [],
premium: false,
playSimilar: client.config.playSimilar,
autoPlay: client.config.autoPlay,
};
return;
}
@ -47,6 +47,6 @@ module.exports = async function (client) {
client.global.db.guilds[guild.id].blacklist = [];
if (!client.global.db.guilds[guild.id].premium)
client.global.db.guilds[guild.id].premium = false;
if (!client.global.db.guilds[guild.id].playSimilar) client.global.db.guilds[guild.id].playSimilar = client.config.playSimilar
if (!client.global.db.guilds[guild.id].autoPlay) client.global.db.guilds[guild.id].autoPlay = client.config.autoPlay
});
};

View File

@ -12,7 +12,7 @@ module.exports = async function (client) {
bass: client.global.db.guilds[guild.id].bass,
blacklist: client.global.db.guilds[guild.id].blacklist,
premium: client.global.db.guilds[guild.id].premium,
playSimilar: client.global.db.guilds[guild.id].playSimilar
autoPlay: client.global.db.guilds[guild.id].autoPlay
});
});
}