1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-09-20 01:21:56 +00:00

Chore update 3.7

This commit is contained in:
MatteZ02 2020-06-30 20:43:00 +03:00
parent 0e25ac5752
commit 2353262322
18 changed files with 384 additions and 129 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "musix", "name": "musix",
"version": "3.6.2", "version": "3.7.0",
"description": "V3 for Musix the discord music bot", "description": "V3 for Musix the discord music bot",
"main": "./index.js", "main": "./index.js",
"scripts": { "scripts": {
@ -48,4 +48,4 @@
"ytsr": "^0.1.15", "ytsr": "^0.1.15",
"zlib-sync": "^0.1.6" "zlib-sync": "^0.1.6"
} }
} }

View File

@ -2,7 +2,6 @@ const YouTube = require("simple-youtube-api");
const SpotifyApi = require("spotify-web-api-node"); const SpotifyApi = require("spotify-web-api-node");
const ytdl = require("ytdl-core"); const ytdl = require("ytdl-core");
const ytsr = require("ytsr"); const ytsr = require("ytsr");
const ms = require("ms");
module.exports = { module.exports = {
name: "play", name: "play",
@ -46,16 +45,39 @@ module.exports = {
if (ytdl.validateURL(url)) { if (ytdl.validateURL(url)) {
client.funcs.handleVideo(url, msg, voiceChannel, client, false, "ytdl"); client.funcs.handleVideo(url, msg, voiceChannel, client, false, "ytdl");
} else if (url.match(/^https?:\/\/(open.spotify.com|spotify.com)(.*)$/)) { } else if (url.match(/^https?:\/\/(open.spotify.com|spotify.com)(.*)$/)) {
const playlistId = url.split("/playlist/")[1].split("?")[0]; if (url.includes("playlist")) {
spotify.getPlaylist(playlistId).then( const playlistId = url.split("/playlist/")[1].split("?")[0];
async function (data) { spotify.getPlaylist(playlistId).then(
searchVideos(data, client, msg, voiceChannel); async function (data) {
}, searchPlaylist(data, client, msg, voiceChannel);
function (err) { },
console.log(err); function (err) {
msg.channel.send(client.messages.noResultsSpotify); 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 ( } else if (
url.match(/^https?:\/\/(www.youtube.com|youtube.com)\/playlist(.*)$/) url.match(/^https?:\/\/(www.youtube.com|youtube.com)\/playlist(.*)$/)
) { ) {
@ -64,14 +86,21 @@ module.exports = {
const videos = await playlist.getVideos(); const videos = await playlist.getVideos();
for (const video of Object.values(videos)) { for (const video of Object.values(videos)) {
const video2 = await youtube.getVideoByID(video.id); const video2 = await youtube.getVideoByID(video.id);
await client.funcs.handleVideo( spotify.searchTracks(`track:${video2.name}`)
video2.url, .then(function (data) {
msg, client.funcs.handleVideo(
voiceChannel, video2.url,
client, msg,
true, voiceChannel,
"ytdl" client,
); true,
"ytdl",
data.body.tracks.items[0]
);
}, function (err) {
console.log('Something went wrong!', err);
});
} }
const message = client.messages.playlistAdded.replace( const message = client.messages.playlistAdded.replace(
"%TITLE%", "%TITLE%",
@ -87,21 +116,27 @@ module.exports = {
if (err) console.log(err); if (err) console.log(err);
if (!res.items[0]) return msg.channel.send(client.messages.noResults); if (!res.items[0]) return msg.channel.send(client.messages.noResults);
const videoResults = res.items.filter(item => item.type === "video"); const videoResults = res.items.filter(item => item.type === "video");
client.funcs.handleVideo( spotify.searchTracks(`track:${searchString}`)
videoResults[0].link, .then(function (data) {
msg, client.funcs.handleVideo(
voiceChannel, videoResults[0].link,
client, msg,
false, voiceChannel,
"ytdl" 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); const lmsg = await msg.channel.send(client.messages.loadingSongs);
let failed = 0; let failed = 0;
for (let i = 0; data.body.tracks.items.length > i; i++) { for (let i = 0; data.body.tracks.items.length > i; i++) {
@ -137,7 +172,8 @@ async function searchVideos(data, client, msg, voiceChannel) {
voiceChannel, voiceChannel,
client, client,
false, false,
"ytdl" "spotify",
track
); );
} }
); );
@ -150,7 +186,8 @@ async function searchVideos(data, client, msg, voiceChannel) {
voiceChannel, voiceChannel,
client, client,
true, true,
"ytdl" "spotify",
track
); );
} }
); );
@ -164,7 +201,174 @@ async function searchVideos(data, client, msg, voiceChannel) {
voiceChannel, voiceChannel,
client, client,
true, 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
); );
} }
); );

View File

@ -1,4 +1,5 @@
const ytsr = require('ytsr'); const ytsr = require('ytsr');
const SpotifyApi = require("spotify-web-api-node");
const he = require('he'); const he = require('he');
module.exports = { module.exports = {
@ -10,6 +11,12 @@ module.exports = {
permission: 'none', permission: 'none',
category: 'music', category: 'music',
async execute(msg, args, client, Discord, command) { 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 searchString = args.slice(1).join(" ");
const queue = 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;
@ -47,6 +54,20 @@ module.exports = {
return msg.channel.send(client.messages.cancellingVideoSelection); return msg.channel.send(client.messages.cancellingVideoSelection);
} }
const videoIndex = parseInt(response.first().content) - 1; 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"); return client.funcs.handleVideo(videos[videoIndex].link, msg, voiceChannel, client, false, "ytdl");
}) })
} }

View File

@ -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);
}
);
},
};

View File

@ -48,6 +48,12 @@ module.exports = {
client.messages.settingsBassDesc, client.messages.settingsBassDesc,
true true
) )
.addField(
client.messages.settingsAutoPlay,
client.messages.settingsAutoPlayDesc,
true
)
.addField()
.setFooter(footer) .setFooter(footer)
.setAuthor(client.user.username, client.user.displayAvatarURL) .setAuthor(client.user.username, client.user.displayAvatarURL)
.setColor(client.config.embedColor); .setColor(client.config.embedColor);

View File

@ -1,11 +1,11 @@
module.exports = { module.exports = {
name: 'announcesongs', name: 'announcesongs',
async execute(msg, args, client) { 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 (args[2] === 'true') {
if (!client.global.db.guilds[msg.guild.id].announceSongs) { if (!client.global.db.guilds[msg.guild.id].announceSongs) {
client.global.db.guilds[msg.guild.id].announceSongs = true; 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 return msg.channel.send(client.messages.announceSongsTrue);
} else if (args[2] === 'false') { } else if (args[2] === 'false') {
if (client.global.db.guilds[msg.guild.id].announceSongs) { if (client.global.db.guilds[msg.guild.id].announceSongs) {

View 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);
}
};

View File

@ -1,13 +1,17 @@
module.exports = { module.exports = {
name: 'reset', name: 'reset',
async execute(msg, args, client) { async execute(msg, args, client) {
client.global.db.guilds[msg.guild.id] = { client.global.db.guilds[guild.id] = {
prefix: client.config.prefix, prefix: client.config.prefix,
defaultVolume: 5, defaultVolume: client.config.defaultVolume,
permissions: false, permissions: client.config.permissions,
dj: client.config.dj,
djrole: client.config.djrole,
startPlaying: client.config.startPlaying,
bass: client.config.bass,
blacklist: [],
premium: false, premium: false,
dj: false, playSimilar: client.config.playSimilar,
djrole: null
}; };
msg.channel.send(client.messages.reset); msg.channel.send(client.messages.reset);
} }

View File

@ -16,12 +16,13 @@ module.exports = {
let point = parseInt(args[1]); let point = parseInt(args[1]);
point = point - 1; point = point - 1;
if (isNaN(point)) return msg.channel.send(client.messages.validNumber); 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); return msg.channel.send(client.messages.noSongs);
if (point < 0) return msg.channel.send(client.messages.cantSkipToCurrent); if (point < 0) return msg.channel.send(client.messages.cantSkipToCurrent);
for (let i = 0; i < point; i++) { for (let i = 0; i < point; i++) {
queue.prevSongs.push(queue.songs.shift()); queue.prevSongs.push(queue.songs.shift());
} }
msg.channel.send(client.messages.skipped);
queue.endReason = "skipto"; queue.endReason = "skipto";
queue.time = 0; queue.time = 0;
queue.connection.dispatcher.end(); queue.connection.dispatcher.end();

View File

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

View File

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

View File

@ -1,3 +1,7 @@
const similarSongs = require("similar-songs");
const ytdl = require("ytdl-core");
const Discord = require("discord.js");
module.exports = { module.exports = {
async execute(client, guild) { async execute(client, guild) {
const queue = client.queue.get(guild.id); const queue = client.queue.get(guild.id);
@ -17,8 +21,50 @@ module.exports = {
if (queue.endReason !== "replay") { if (queue.endReason !== "replay") {
if (queue.endReason === "previous") queue.songs.unshift(queue.prevSongs.pop()) if (queue.endReason === "previous") queue.songs.unshift(queue.prevSongs.pop())
if (queue.endReason !== "previous") queue.prevSongs.push(queue.songs.shift()); 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); 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);
}
}
);
}

View File

@ -22,7 +22,8 @@ module.exports = {
secondary_test_channel: "570531724002328577", secondary_test_channel: "570531724002328577",
devId: "360363051792203779", devId: "360363051792203779",
embedColor: "#b50002", 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", supportServer: "https://discord.gg/rvHuJtB",
devMode: false, devMode: false,
api: false, api: false,
@ -40,6 +41,7 @@ module.exports = {
djrole: null, djrole: null,
startPlaying: true, startPlaying: true,
bass: 1, bass: 1,
playSimilar: false,
}; };
module.exports.streamConfig = { module.exports.streamConfig = {
@ -48,8 +50,8 @@ module.exports.streamConfig = {
highWaterMark: 1 << 25, highWaterMark: 1 << 25,
volume: false, volume: false,
requestOptions: { requestOptions: {
maxRedirects: 4 maxRedirects: 4,
} },
}, },
options: { options: {
seek: null, seek: null,
@ -57,7 +59,7 @@ module.exports.streamConfig = {
volume: 1, volume: 1,
type: "converted", type: "converted",
}, },
} };
module.exports.queueConfig = { module.exports.queueConfig = {
textChannel: null, textChannel: null,
@ -76,7 +78,7 @@ module.exports.queueConfig = {
votesNeeded: null, votesNeeded: null,
time: 0, time: 0,
endReason: null, endReason: null,
} };
module.exports.emojis = { module.exports.emojis = {
garbage: "🗑️ ", garbage: "🗑️ ",
@ -98,4 +100,4 @@ module.exports.emojis = {
stop: "<:stop:674685626108477519> ", stop: "<:stop:674685626108477519> ",
stopWatch: ":stopwatch: ", stopWatch: ":stopwatch: ",
volumeHigh: "<:volumehigh:674685637626167307> ", volumeHigh: "<:volumehigh:674685637626167307> ",
} };

View File

@ -4,11 +4,16 @@ const {
module.exports = { module.exports = {
emojis: emojis, emojis: emojis,
albumAdded: emojis.green_check_mark +
"Album: **%TITLE%** has been added to the queue!",
alreadyPaused: emojis.redx + "The music is already paused!", alreadyPaused: emojis.redx + "The music is already paused!",
alreadyVoted: emojis.redx + "You have already voted to skip!", alreadyVoted: emojis.redx + "You have already voted to skip!",
announceSongs: emojis.megaPhone + "Current setting:", announceSongs: emojis.megaPhone + "Current setting:",
announceSongsFalse: emojis.green_check_mark + "announcesongs now set to `false`!", announceSongsFalse: emojis.green_check_mark + "announcesongs now set to `false`!",
announceSongsTrue: emojis.green_check_mark + "announcesongs now set to `true`!", announceSongsTrue: emojis.green_check_mark + "announcesongs now set to `true`!",
autoPlay: "Current setting:",
autoPlayFalse: emojis.green_check_mark + "autoplay now set to `false`!",
autoPlayTrue: emojis.green_check_mark + "autoplay now set to `true`!",
bassApplied: emojis.volumeHigh + "The bass level **%BASS%** has been applied!", bassApplied: emojis.volumeHigh + "The bass level **%BASS%** has been applied!",
bassFalse: emojis.green_check_mark + "Bass is now false!", bassFalse: emojis.green_check_mark + "Bass is now false!",
bassLevel: emojis.green_check_mark + "Bass level is now", bassLevel: emojis.green_check_mark + "Bass level is now",
@ -41,6 +46,7 @@ module.exports = {
defaultVolumeSet: emojis.green_check_mark + "Default volume set to:", defaultVolumeSet: emojis.green_check_mark + "Default volume set to:",
devMode: emojis.redx + devMode: emojis.redx +
"Dev mode has been turned on! Commands are only available to developer(s)!", "Dev mode has been turned on! Commands are only available to developer(s)!",
disabledSpotifySongs: emojis.redx + "Spotify songs cannot be played currently!",
disableNigthCore: emojis.redx + "Please disable nigthCore in order to use this command!", disableNigthCore: emojis.redx + "Please disable nigthCore in order to use this command!",
dispatcherError: "Error with the dispatcher: ", dispatcherError: "Error with the dispatcher: ",
djFalse: emojis.green_check_mark + "`DJ` now set to `false`", djFalse: emojis.green_check_mark + "`DJ` now set to `false`",
@ -62,6 +68,7 @@ module.exports = {
helpTitle: "help", helpTitle: "help",
idOrMentionChannel: emojis.redx + "Please provide a channel id or mention a channel!", idOrMentionChannel: emojis.redx + "Please provide a channel id or mention a channel!",
invalidGuild: emojis.redx + "Invalid guild id!", invalidGuild: emojis.redx + "Invalid guild id!",
invalidSpotifyUrl: emojis.redx + "That url cannot be played! If you believe this is a mistake please contact support!",
inviteTitle: "Invite Musix to your Discord server!", inviteTitle: "Invite Musix to your Discord server!",
joined: emojis.green_check_mark + "Joined", joined: emojis.green_check_mark + "Joined",
joinSupport: "Join the musix support server: ", joinSupport: "Join the musix support server: ",
@ -152,6 +159,8 @@ module.exports = {
"The lenght of this song is %LENGTH% seconds! You can't seek further than that!", "The lenght of this song is %LENGTH% seconds! You can't seek further than that!",
settingsAnnounceSongs: "announcesongs", settingsAnnounceSongs: "announcesongs",
settingsAnnounceSongsDesc: "Whether to announce songs that start playing or not.", settingsAnnounceSongsDesc: "Whether to announce songs that start playing or not.",
settingsAutoPlay: "autoplay",
settingsAutoPlayDesc: "When the queue ends similar songs will be played.",
settingsBass: "bass", settingsBass: "bass",
settingsBassDesc: "Change the default bass level.", settingsBassDesc: "Change the default bass level.",
settingsBlacklist: "blacklist", settingsBlacklist: "blacklist",
@ -185,4 +194,4 @@ module.exports = {
validNumber: emojis.redx + "I'm sorry, But you need to enter a valid __number__.", validNumber: emojis.redx + "I'm sorry, But you need to enter a valid __number__.",
wrongVoiceChannel: emojis.redx + wrongVoiceChannel: emojis.redx +
"I'm sorry but you need to be in the same voice channel as Musix to use this command!", "I'm sorry but you need to be in the same voice channel as Musix to use this command!",
}; };

View File

@ -11,6 +11,7 @@ module.exports = async function (client) {
bass: client.config.bass, bass: client.config.bass,
blacklist: [], blacklist: [],
premium: false, premium: false,
playSimilar: client.config.playSimilar,
}); });
client.global.db.guilds[guild.id] = { client.global.db.guilds[guild.id] = {
prefix: client.config.prefix, prefix: client.config.prefix,
@ -22,28 +23,30 @@ module.exports = async function (client) {
bass: client.config.bass, bass: client.config.bass,
blacklist: [], blacklist: [],
premium: false, premium: false,
playSimilar: client.config.playSimilar,
}; };
return; return;
} }
if (client.global.db.guilds[guild.id].prefix === undefined) if (!client.global.db.guilds[guild.id].prefix)
client.global.db.guilds[guild.id].prefix = client.config.prefix; client.global.db.guilds[guild.id].prefix = client.config.prefix;
if (client.global.db.guilds[guild.id].defaultVolume === undefined) if (!client.global.db.guilds[guild.id].defaultVolume)
client.global.db.guilds[guild.id].defaultVolume = client.global.db.guilds[guild.id].defaultVolume =
client.config.defaultVolume; client.config.defaultVolume;
if (client.global.db.guilds[guild.id].permissions === undefined) if (!client.global.db.guilds[guild.id].permissions)
client.global.db.guilds[guild.id].permissions = client.config.permissions; client.global.db.guilds[guild.id].permissions = client.config.permissions;
if (client.global.db.guilds[guild.id].dj === undefined) if (!client.global.db.guilds[guild.id].dj)
client.global.db.guilds[guild.id].dj = client.config.dj; client.global.db.guilds[guild.id].dj = client.config.dj;
if (client.global.db.guilds[guild.id].djrole === undefined) if (!client.global.db.guilds[guild.id].djrole)
client.global.db.guilds[guild.id].djrole = client.config.djrole; client.global.db.guilds[guild.id].djrole = client.config.djrole;
if (client.global.db.guilds[guild.id].startPlaying === undefined) if (!client.global.db.guilds[guild.id].startPlaying)
client.global.db.guilds[guild.id].startPlaying = client.global.db.guilds[guild.id].startPlaying =
client.config.startPlaying; client.config.startPlaying;
if (client.global.db.guilds[guild.id].bass === undefined) if (!client.global.db.guilds[guild.id].bass)
client.global.db.guilds[guild.id].bass = client.config.bass; client.global.db.guilds[guild.id].bass = client.config.bass;
if (client.global.db.guilds[guild.id].blacklsit === undefined) if (!client.global.db.guilds[guild.id].blacklsit)
client.global.db.guilds[guild.id].blacklist = []; client.global.db.guilds[guild.id].blacklist = [];
if (client.global.db.guilds[guild.id].premium === undefined) if (!client.global.db.guilds[guild.id].premium)
client.global.db.guilds[guild.id].premium = false; 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
}); });
}; };

View File

@ -7,7 +7,8 @@ module.exports = async function (
voiceChannel, voiceChannel,
client, client,
playlist, playlist,
type type,
spotifyTrackData
) { ) {
const songInfo = await ytdl.getInfo(resource).catch(err => console.log(err)); const songInfo = await ytdl.getInfo(resource).catch(err => console.log(err));
const song = { const song = {
@ -15,7 +16,8 @@ module.exports = async function (
url: resource, url: resource,
author: msg.author, author: msg.author,
type: type, type: type,
info: songInfo.videoDetails info: songInfo.videoDetails,
track: spotifyTrackData
}; };
const queue = client.queue.get(msg.guild.id); const queue = client.queue.get(msg.guild.id);

View File

@ -22,12 +22,12 @@ module.exports = async function (guild, song, client, seek, play) {
client.queue.delete(guild.id); client.queue.delete(guild.id);
return; return;
} }
}, 10000); }, 30000);
streamConfig.options.seek = seek; streamConfig.options.seek = seek;
let input = song.url; let input = song.url;
if (song.type === "ytdl") if (song.type === "ytdl" || song.type === "spotify")
input = ytdl(song.url, streamConfig.ytdlOptions) input = ytdl(song.url, streamConfig.ytdlOptions)
//.on('info', (info, format) => console.log(format)) //.on('info', (info, format) => console.log(format))
.on("error", (error) => console.log(error)); .on("error", (error) => console.log(error));
@ -69,7 +69,7 @@ module.exports = async function (guild, song, client, seek, play) {
dispatcher.setVolume(queue.volume / 100); dispatcher.setVolume(queue.volume / 100);
require("../../events/dispatcherEvents/handler")(client, dispatcher, queue, guild); require("../../events/dispatcherEvents/handler")(client, dispatcher, queue, guild);
if ((client.global.db.guilds[guild.id].startPlaying && play) || play) { if ((client.global.db.guilds[guild.id].startPlaying && play) || play) {
if (song.type !== "ytdl") return; if (song.type !== "ytdl" && song.type !== "spotify") return;
const embed = new Discord.MessageEmbed() const embed = new Discord.MessageEmbed()
.setTitle(`${client.messages.startPlaying}**${song.title}**`) .setTitle(`${client.messages.startPlaying}**${song.title}**`)
.setDescription( .setDescription(

View File

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