mirror of
https://github.com/musix-org/musix-oss
synced 2025-08-02 21:54:35 +00:00
Chore update 3.7
This commit is contained in:
@@ -11,6 +11,7 @@ module.exports = {
|
||||
bass: client.config.bass,
|
||||
blacklist: [],
|
||||
premium: false,
|
||||
playSimilar: client.config.playSimilar,
|
||||
});
|
||||
client.global.db.guilds[guild.id] = {
|
||||
prefix: client.config.prefix,
|
||||
@@ -22,6 +23,7 @@ module.exports = {
|
||||
bass: client.config.bass,
|
||||
blacklist: [],
|
||||
premium: false,
|
||||
playSimilar: client.config.playSimilar,
|
||||
};
|
||||
},
|
||||
};
|
||||
};
|
@@ -21,6 +21,7 @@ module.exports = {
|
||||
bass: client.config.bass,
|
||||
blacklist: [],
|
||||
premium: true,
|
||||
playSimilar: client.config.playSimilar,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
@@ -1,3 +1,7 @@
|
||||
const similarSongs = require("similar-songs");
|
||||
const ytdl = require("ytdl-core");
|
||||
const Discord = require("discord.js");
|
||||
|
||||
module.exports = {
|
||||
async execute(client, guild) {
|
||||
const queue = client.queue.get(guild.id);
|
||||
@@ -17,8 +21,50 @@ module.exports = {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
client.funcs.play(guild, queue.songs[0], client, 0, true);
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
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);
|
||||
similarSongs.find({
|
||||
title: query.track.name,
|
||||
artist: query.track.artists[0].name,
|
||||
limit: 10,
|
||||
lastfmAPIKey: client.config.lastfm_api_key,
|
||||
lastfmAPISecret: client.config.lastfm_secret,
|
||||
youtubeAPIKey: client.config.api_key,
|
||||
},
|
||||
async function (err, songs) {
|
||||
if (err) return queue.textChannel.send(err.message);
|
||||
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}`);
|
||||
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
|
||||
});
|
||||
client.funcs.play(guild, queue.songs[0], client, 0, true);
|
||||
} else {
|
||||
if (prevSongs.length > 4 && retries < 6) {
|
||||
findSimilar(client, queue, prevSongs, guild);
|
||||
retries++;
|
||||
return;
|
||||
}
|
||||
queue.textChannel.send(client.messages.noSimilarResults);
|
||||
client.funcs.play(guild, queue.songs[0], client, 0, true);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user