mirror of
https://github.com/musix-org/musix-oss
synced 2025-07-03 16:24:28 +00:00
Chore update 3.7
This commit is contained in:
@ -2,7 +2,6 @@ const YouTube = require("simple-youtube-api");
|
||||
const SpotifyApi = require("spotify-web-api-node");
|
||||
const ytdl = require("ytdl-core");
|
||||
const ytsr = require("ytsr");
|
||||
const ms = require("ms");
|
||||
|
||||
module.exports = {
|
||||
name: "play",
|
||||
@ -46,16 +45,39 @@ module.exports = {
|
||||
if (ytdl.validateURL(url)) {
|
||||
client.funcs.handleVideo(url, msg, voiceChannel, client, false, "ytdl");
|
||||
} else if (url.match(/^https?:\/\/(open.spotify.com|spotify.com)(.*)$/)) {
|
||||
const playlistId = url.split("/playlist/")[1].split("?")[0];
|
||||
spotify.getPlaylist(playlistId).then(
|
||||
async function (data) {
|
||||
searchVideos(data, client, msg, voiceChannel);
|
||||
},
|
||||
function (err) {
|
||||
console.log(err);
|
||||
msg.channel.send(client.messages.noResultsSpotify);
|
||||
}
|
||||
);
|
||||
if (url.includes("playlist")) {
|
||||
const playlistId = url.split("/playlist/")[1].split("?")[0];
|
||||
spotify.getPlaylist(playlistId).then(
|
||||
async function (data) {
|
||||
searchPlaylist(data, client, msg, voiceChannel);
|
||||
},
|
||||
function (err) {
|
||||
console.log(err);
|
||||
msg.channel.send(client.messages.noResultsSpotify);
|
||||
}
|
||||
);
|
||||
} else if (url.includes("album")) {
|
||||
const albumId = url.split("/album/")[1].split("?")[0];
|
||||
spotify.getAlbumTracks(albumId)
|
||||
.then(
|
||||
async function (data) {
|
||||
searchAlbum(data, client, msg, voiceChannel);
|
||||
},
|
||||
function (err) {
|
||||
console.log(err);
|
||||
msg.channel.send(client.messages.noResultsSpotify);
|
||||
}
|
||||
);
|
||||
} else if (url.includes("track")) {
|
||||
return msg.channel.send(client.messages.disabledSpotifySongs);
|
||||
/*const trackId = url.split("/track/")[1].split("?")[0];
|
||||
spotify.searchTracks(trackId)
|
||||
.then(function (data) {
|
||||
console.log(data.body)
|
||||
}, function (err) {
|
||||
console.log('Something went wrong!', err);
|
||||
});*/
|
||||
} else msg.channel.send(client.messages.invalidSpotifyUrl)
|
||||
} else if (
|
||||
url.match(/^https?:\/\/(www.youtube.com|youtube.com)\/playlist(.*)$/)
|
||||
) {
|
||||
@ -64,14 +86,21 @@ module.exports = {
|
||||
const videos = await playlist.getVideos();
|
||||
for (const video of Object.values(videos)) {
|
||||
const video2 = await youtube.getVideoByID(video.id);
|
||||
await client.funcs.handleVideo(
|
||||
video2.url,
|
||||
msg,
|
||||
voiceChannel,
|
||||
client,
|
||||
true,
|
||||
"ytdl"
|
||||
);
|
||||
spotify.searchTracks(`track:${video2.name}`)
|
||||
.then(function (data) {
|
||||
client.funcs.handleVideo(
|
||||
video2.url,
|
||||
msg,
|
||||
voiceChannel,
|
||||
client,
|
||||
true,
|
||||
"ytdl",
|
||||
data.body.tracks.items[0]
|
||||
);
|
||||
}, function (err) {
|
||||
console.log('Something went wrong!', err);
|
||||
});
|
||||
|
||||
}
|
||||
const message = client.messages.playlistAdded.replace(
|
||||
"%TITLE%",
|
||||
@ -87,21 +116,27 @@ module.exports = {
|
||||
if (err) console.log(err);
|
||||
if (!res.items[0]) return msg.channel.send(client.messages.noResults);
|
||||
const videoResults = res.items.filter(item => item.type === "video");
|
||||
client.funcs.handleVideo(
|
||||
videoResults[0].link,
|
||||
msg,
|
||||
voiceChannel,
|
||||
client,
|
||||
false,
|
||||
"ytdl"
|
||||
);
|
||||
spotify.searchTracks(`track:${searchString}`)
|
||||
.then(function (data) {
|
||||
client.funcs.handleVideo(
|
||||
videoResults[0].link,
|
||||
msg,
|
||||
voiceChannel,
|
||||
client,
|
||||
false,
|
||||
"ytdl",
|
||||
data.body.tracks.items[0]
|
||||
);
|
||||
}, function (err) {
|
||||
console.log('Something went wrong!', err);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
async function searchVideos(data, client, msg, voiceChannel) {
|
||||
async function searchPlaylist(data, client, msg, voiceChannel) {
|
||||
const lmsg = await msg.channel.send(client.messages.loadingSongs);
|
||||
let failed = 0;
|
||||
for (let i = 0; data.body.tracks.items.length > i; i++) {
|
||||
@ -137,7 +172,8 @@ async function searchVideos(data, client, msg, voiceChannel) {
|
||||
voiceChannel,
|
||||
client,
|
||||
false,
|
||||
"ytdl"
|
||||
"spotify",
|
||||
track
|
||||
);
|
||||
}
|
||||
);
|
||||
@ -150,7 +186,8 @@ async function searchVideos(data, client, msg, voiceChannel) {
|
||||
voiceChannel,
|
||||
client,
|
||||
true,
|
||||
"ytdl"
|
||||
"spotify",
|
||||
track
|
||||
);
|
||||
}
|
||||
);
|
||||
@ -164,7 +201,174 @@ async function searchVideos(data, client, msg, voiceChannel) {
|
||||
voiceChannel,
|
||||
client,
|
||||
true,
|
||||
"ytdl"
|
||||
"spotify",
|
||||
track
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
let message;
|
||||
if (failed === 0) {
|
||||
message = client.messages.playlistAdded.replace("%TITLE%", data.body.name);
|
||||
} else {
|
||||
message = `${client.messages.playlistAdded.replace(
|
||||
"%TITLE%",
|
||||
data.body.name
|
||||
)}\n${client.messages.failedToLoad + failed}`;
|
||||
}
|
||||
lmsg.edit(message);
|
||||
}
|
||||
|
||||
async function searchAlbum(data, client, msg, voiceChannel) {
|
||||
const lmsg = await msg.channel.send(client.messages.loadingSongs);
|
||||
let failed = 0;
|
||||
for (let i = 0; data.body.items.length > i; i++) {
|
||||
const track = await data.body.items[i];
|
||||
await client.funcs.sleep(250);
|
||||
ytsr(
|
||||
`${track.artists[0].name} ${track.name} audio`, {
|
||||
limit: 5,
|
||||
},
|
||||
async function (err, res) {
|
||||
if (err) return console.log(err);
|
||||
if (!res.items[0]) {
|
||||
ytsr(
|
||||
`${track.artists[0].name} ${track.name} lyrics`, {
|
||||
limit: 5,
|
||||
},
|
||||
async function (err, res) {
|
||||
if (err) return console.log(err);
|
||||
if (!res.items[0]) {
|
||||
ytsr(
|
||||
`${track.artists[0].name} ${track.name}`, {
|
||||
limit: 5,
|
||||
},
|
||||
async function (err, res) {
|
||||
if (err) console.log(err);
|
||||
if (!res.items[0]) {
|
||||
failed++;
|
||||
}
|
||||
const videoResults = res.items.filter(item => item.type === "video");
|
||||
client.funcs.handleVideo(
|
||||
videoResults[0].link,
|
||||
msg,
|
||||
voiceChannel,
|
||||
client,
|
||||
false,
|
||||
"spotify",
|
||||
track
|
||||
);
|
||||
}
|
||||
);
|
||||
return;
|
||||
}
|
||||
const videoResults = res.items.filter(item => item.type === "video");
|
||||
await client.funcs.handleVideo(
|
||||
videoResults[0].link,
|
||||
msg,
|
||||
voiceChannel,
|
||||
client,
|
||||
true,
|
||||
"spotify",
|
||||
track
|
||||
);
|
||||
}
|
||||
);
|
||||
failed++;
|
||||
return;
|
||||
}
|
||||
const videoResults = res.items.filter(item => item.type === "video");
|
||||
await client.funcs.handleVideo(
|
||||
videoResults[0].link,
|
||||
msg,
|
||||
voiceChannel,
|
||||
client,
|
||||
true,
|
||||
"spotify",
|
||||
track
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
let message;
|
||||
if (failed === 0) {
|
||||
message = client.messages.albumAdded.replace("%TITLE%", "yes taht palylist");
|
||||
} else {
|
||||
message = `${client.messages.albumAdded.replace(
|
||||
"%TITLE%",
|
||||
"yes taht palylist"
|
||||
)}\n${client.messages.failedToLoad + failed}`;
|
||||
}
|
||||
lmsg.edit(message);
|
||||
}
|
||||
|
||||
async function searchSong(data, client, msg, voiceChannel) {
|
||||
const lmsg = await msg.channel.send(client.messages.loadingSongs);
|
||||
let failed = 0;
|
||||
for (let i = 0; data.body.tracks.items.length > i; i++) {
|
||||
const track = await data.body.tracks.items[i].track;
|
||||
await client.funcs.sleep(250);
|
||||
ytsr(
|
||||
`${track.artists[0].name} ${track.name} audio`, {
|
||||
limit: 5,
|
||||
},
|
||||
async function (err, res) {
|
||||
if (err) return console.log(err);
|
||||
if (!res.items[0]) {
|
||||
ytsr(
|
||||
`${track.artists[0].name} ${track.name} lyrics`, {
|
||||
limit: 5,
|
||||
},
|
||||
async function (err, res) {
|
||||
if (err) return console.log(err);
|
||||
if (!res.items[0]) {
|
||||
ytsr(
|
||||
`${track.artists[0].name} ${track.name}`, {
|
||||
limit: 5,
|
||||
},
|
||||
async function (err, res) {
|
||||
if (err) console.log(err);
|
||||
if (!res.items[0]) {
|
||||
failed++;
|
||||
}
|
||||
const videoResults = res.items.filter(item => item.type === "video");
|
||||
client.funcs.handleVideo(
|
||||
videoResults[0].link,
|
||||
msg,
|
||||
voiceChannel,
|
||||
client,
|
||||
false,
|
||||
"spotify",
|
||||
track
|
||||
);
|
||||
}
|
||||
);
|
||||
return;
|
||||
}
|
||||
const videoResults = res.items.filter(item => item.type === "video");
|
||||
await client.funcs.handleVideo(
|
||||
videoResults[0].link,
|
||||
msg,
|
||||
voiceChannel,
|
||||
client,
|
||||
true,
|
||||
"spotify",
|
||||
track
|
||||
);
|
||||
}
|
||||
);
|
||||
failed++;
|
||||
return;
|
||||
}
|
||||
const videoResults = res.items.filter(item => item.type === "video");
|
||||
await client.funcs.handleVideo(
|
||||
videoResults[0].link,
|
||||
msg,
|
||||
voiceChannel,
|
||||
client,
|
||||
true,
|
||||
"spotify",
|
||||
track
|
||||
);
|
||||
}
|
||||
);
|
||||
|
@ -1,4 +1,5 @@
|
||||
const ytsr = require('ytsr');
|
||||
const SpotifyApi = require("spotify-web-api-node");
|
||||
const he = require('he');
|
||||
|
||||
module.exports = {
|
||||
@ -10,6 +11,12 @@ module.exports = {
|
||||
permission: 'none',
|
||||
category: 'music',
|
||||
async execute(msg, args, client, Discord, command) {
|
||||
const spotify = new SpotifyApi({
|
||||
id: client.config.spotify_client_id,
|
||||
secret: client.config.spotify_client_secret,
|
||||
});
|
||||
spotify.setAccessToken(client.config.spotify_access_key);
|
||||
|
||||
const searchString = args.slice(1).join(" ");
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
const voiceChannel = msg.member.voice.channel;
|
||||
@ -47,6 +54,20 @@ module.exports = {
|
||||
return msg.channel.send(client.messages.cancellingVideoSelection);
|
||||
}
|
||||
const videoIndex = parseInt(response.first().content) - 1;
|
||||
spotify.searchTracks(`track:${videos[videoIndex].title}`)
|
||||
.then(function (data) {
|
||||
client.funcs.handleVideo(
|
||||
videoResults[0].link,
|
||||
msg,
|
||||
voiceChannel,
|
||||
client,
|
||||
false,
|
||||
"ytdl",
|
||||
data.body.tracks.items[0]
|
||||
);
|
||||
}, function (err) {
|
||||
console.log('Something went wrong!', err);
|
||||
});
|
||||
return client.funcs.handleVideo(videos[videoIndex].link, msg, voiceChannel, client, false, "ytdl");
|
||||
})
|
||||
}
|
||||
|
@ -1,64 +0,0 @@
|
||||
const similarSongs = require("similar-songs");
|
||||
|
||||
module.exports = {
|
||||
name: "searchsimilar",
|
||||
alias: ["none"],
|
||||
usage: "<song name>, <artist>",
|
||||
description: "a command to search similar songs (in developement)",
|
||||
onlyDev: false,
|
||||
permission: "none",
|
||||
category: "music",
|
||||
async execute(msg, args, client, Discord, command) {
|
||||
const searchString = args.slice(1).join(" ");
|
||||
const query = searchString.split(",");
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
const voiceChannel = msg.member.voice.channel;
|
||||
if (
|
||||
client.global.db.guilds[msg.guild.id].blacklist.includes(
|
||||
msg.member.voice.channelID
|
||||
)
|
||||
)
|
||||
return msg.channel.send(client.messages.blackListedVC);
|
||||
if (!queue) {
|
||||
if (!msg.member.voice.channel)
|
||||
return msg.channel.send(client.messages.noVoiceChannel);
|
||||
} else {
|
||||
if (voiceChannel !== queue.voiceChannel)
|
||||
return msg.channel.send(client.messages.wrongVoiceChannel);
|
||||
}
|
||||
if (!query[0] || !query[1]) {
|
||||
const message = client.messages.searchSimilarUsage.replace("%USAGE%", command.usage);
|
||||
return msg.channel.send(message);
|
||||
|
||||
}
|
||||
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);
|
||||
similarSongs.find({
|
||||
title: query[0],
|
||||
artist: query[1].slice(1),
|
||||
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 msg.channel.send(err.message);
|
||||
if (songs.length !== 0) {
|
||||
const lmsg = await msg.channel.send(client.messages.loadingSongs);
|
||||
for (let i = 0; i < songs.length; i++) {
|
||||
client.funcs.handleVideo(
|
||||
`https://www.youtube.com/watch?v=${songs[i].youtubeId}`, msg, voiceChannel, client, true, "ytdl");
|
||||
}
|
||||
const message = client.messages.songsAdded.replace(
|
||||
"%AMOUNT%",
|
||||
songs.length
|
||||
);
|
||||
return lmsg.edit(message);
|
||||
} else return msg.channel.send(client.messages.noSimilarResults);
|
||||
}
|
||||
);
|
||||
},
|
||||
};
|
@ -48,6 +48,12 @@ module.exports = {
|
||||
client.messages.settingsBassDesc,
|
||||
true
|
||||
)
|
||||
.addField(
|
||||
client.messages.settingsAutoPlay,
|
||||
client.messages.settingsAutoPlayDesc,
|
||||
true
|
||||
)
|
||||
.addField()
|
||||
.setFooter(footer)
|
||||
.setAuthor(client.user.username, client.user.displayAvatarURL)
|
||||
.setColor(client.config.embedColor);
|
||||
|
@ -1,11 +1,11 @@
|
||||
module.exports = {
|
||||
name: 'announcesongs',
|
||||
async execute(msg, args, client) {
|
||||
if (!args[2]) return msg.channel.send(`${client.messages.announceSongs} \`${client.global.db.guilds[msg.guild.id].permissions}\``);
|
||||
if (!args[2]) return msg.channel.send(`${client.messages.announceSongs} \`${client.global.db.guilds[msg.guild.id].announceSongs}\``);
|
||||
if (args[2] === 'true') {
|
||||
if (!client.global.db.guilds[msg.guild.id].announceSongs) {
|
||||
client.global.db.guilds[msg.guild.id].announceSongs = true;
|
||||
msg.channel.send(client.messages.permissionsSetTrue);
|
||||
msg.channel.send(client.messages.announceSongsTrue);
|
||||
} else return msg.channel.send(client.messages.announceSongsTrue);
|
||||
} else if (args[2] === 'false') {
|
||||
if (client.global.db.guilds[msg.guild.id].announceSongs) {
|
||||
|
17
src/commands/settings/autoPlay.js
Normal file
17
src/commands/settings/autoPlay.js
Normal file
@ -0,0 +1,17 @@
|
||||
module.exports = {
|
||||
name: 'autoplay',
|
||||
async execute(msg, args, client) {
|
||||
if (!args[2]) return msg.channel.send(`${client.messages.autoPlay} \`${client.global.db.guilds[msg.guild.id].autoPlay}\``);
|
||||
if (args[2] === 'true') {
|
||||
if (!client.global.db.guilds[msg.guild.id].autoPlay) {
|
||||
client.global.db.guilds[msg.guild.id].autoPlay = true;
|
||||
msg.channel.send(client.messages.autoPlayTrue);
|
||||
} else return msg.channel.send(client.messages.autoPlayTrue);
|
||||
} else if (args[2] === 'false') {
|
||||
if (client.global.db.guilds[msg.guild.id].autoPlay) {
|
||||
client.global.db.guilds[msg.guild.id].autoPlay = false;
|
||||
msg.channel.send(client.messages.autoPlayFalse);
|
||||
} else return msg.channel.send(client.messages.autoPlayFalse);
|
||||
} else return msg.channel.send(client.messages.boolean);
|
||||
}
|
||||
};
|
@ -1,13 +1,17 @@
|
||||
module.exports = {
|
||||
name: 'reset',
|
||||
async execute(msg, args, client) {
|
||||
client.global.db.guilds[msg.guild.id] = {
|
||||
client.global.db.guilds[guild.id] = {
|
||||
prefix: client.config.prefix,
|
||||
defaultVolume: 5,
|
||||
permissions: false,
|
||||
defaultVolume: client.config.defaultVolume,
|
||||
permissions: client.config.permissions,
|
||||
dj: client.config.dj,
|
||||
djrole: client.config.djrole,
|
||||
startPlaying: client.config.startPlaying,
|
||||
bass: client.config.bass,
|
||||
blacklist: [],
|
||||
premium: false,
|
||||
dj: false,
|
||||
djrole: null
|
||||
playSimilar: client.config.playSimilar,
|
||||
};
|
||||
msg.channel.send(client.messages.reset);
|
||||
}
|
||||
|
@ -16,12 +16,13 @@ module.exports = {
|
||||
let point = parseInt(args[1]);
|
||||
point = point - 1;
|
||||
if (isNaN(point)) return msg.channel.send(client.messages.validNumber);
|
||||
if (point > queue.songs.size)
|
||||
if (point > queue.songs.length - 1)
|
||||
return msg.channel.send(client.messages.noSongs);
|
||||
if (point < 0) return msg.channel.send(client.messages.cantSkipToCurrent);
|
||||
for (let i = 0; i < point; i++) {
|
||||
queue.prevSongs.push(queue.songs.shift());
|
||||
}
|
||||
msg.channel.send(client.messages.skipped);
|
||||
queue.endReason = "skipto";
|
||||
queue.time = 0;
|
||||
queue.connection.dispatcher.end();
|
||||
|
Reference in New Issue
Block a user