1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-12-22 21:13:18 +00:00

remove setkey

This commit is contained in:
MatteZ02 2020-04-21 22:19:40 +03:00
parent 32ae8cbb6e
commit e829eeaf8f
5 changed files with 72 additions and 98 deletions

View File

@ -42,88 +42,86 @@ module.exports = {
if (!voiceChannel.speakable)
return msg.channel.send(client.messages.noPermsSpeak);
if (url.match(/^https?:\/\/(open.spotify.com|spotify.com)(.*)$/)) {
if (!client.global.db.guilds[msg.guild.id].premium)
return msg.channel.send(client.messages.notPremium);
const playlistId = url.split("/playlist/")[1].split("?")[0];
spotify.getPlaylist(playlistId).then(
async function (data) {
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);
await search(
`${track.artists[0].name} ${track.name} audio`,
async function (err, res) {
if (err) return console.log(err);
if (res.videos.length === 0) {
await search(
`${track.artists[0].name} ${track.name} lyrics`,
async function (err, res) {
if (err) return console.log(err);
if (res.videos.length === 0) {
await search(
`${track.artists[0].name} ${track.name}`,
async function (err, res) {
if (err) return console.log(err);
if (res.videos.length === 0) {
failed++;
return;
}
await client.funcs.handleVideo(
res.videos[0],
msg,
voiceChannel,
client,
true,
"ytdl"
);
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);
await search(
`${track.artists[0].name} ${track.name} audio`,
async function (err, res) {
if (err) return console.log(err);
if (res.videos.length === 0) {
await search(
`${track.artists[0].name} ${track.name} lyrics`,
async function (err, res) {
if (err) return console.log(err);
if (res.videos.length === 0) {
await search(
`${track.artists[0].name} ${track.name}`,
async function (err, res) {
if (err) return console.log(err);
if (res.videos.length === 0) {
failed++;
return;
}
);
return;
}
await client.funcs.handleVideo(
res.videos[0],
msg,
voiceChannel,
client,
true,
"ytdl"
await client.funcs.handleVideo(
res.videos[0],
msg,
voiceChannel,
client,
true,
"ytdl"
);
}
);
return;
}
);
failed++;
return;
}
await client.funcs.handleVideo(
res.videos[0],
msg,
voiceChannel,
client,
true,
"ytdl"
await client.funcs.handleVideo(
res.videos[0],
msg,
voiceChannel,
client,
true,
"ytdl"
);
}
);
failed++;
return;
}
);
}
let message;
if (failed === 0) {
message = client.messages.playlistAdded.replace(
"%TITLE%",
data.body.name
);
} else {
message = `${client.messages.playlistAdded.replace(
await client.funcs.handleVideo(
res.videos[0],
msg,
voiceChannel,
client,
true,
"ytdl"
);
}
);
}
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);
},
function (err) {
console.log(err);
msg.channel.send(client.messages.noResultsSpotify);
}
lmsg.edit(message);
},
function (err) {
console.log(err);
msg.channel.send(client.messages.noResultsSpotify);
}
);
} else if (
url.match(/^https?:\/\/(www.youtube.com|youtube.com)\/playlist(.*)$/)
@ -164,4 +162,4 @@ module.exports = {
});
}
},
};
};

View File

@ -48,11 +48,6 @@ module.exports = {
client.messages.settingsBassDesc,
true
)
.addField(
client.messages.settingsSetKey,
client.messages.settingsSetKeyDesc,
true
)
.setFooter(footer)
.setAuthor(client.user.username, client.user.displayAvatarURL)
.setColor(client.config.embedColor);
@ -87,4 +82,4 @@ module.exports = {
return msg.channel.send(embed);
}
},
};
};

View File

@ -1,6 +0,0 @@
module.exports = {
name: "setkey",
async execute(msg, args, client) {
msg.channel.send(client.messages.setKeyUsage);
},
};

View File

@ -1,17 +1,7 @@
module.exports = {
name: "message",
async execute(client, msg, Discord) {
if (msg.author.bot) return;
if (!msg.guild && msg.content.startsWith("setkey")) {
const args = msg.content.split(" ");
if (!args[1] || !args[2])
return msg.channel.send(client.messages.setKeyUsage);
client.config.db.collection("guilds").doc(args[2]).set({
key: args[1],
});
return msg.channel.send(client.messages.keySet);
}
if (!msg.guild) return;
if (msg.author.bot || !msg.guild) return;
if (!client.global.db.guilds[msg.guild.id]) return;
let prefix = client.global.db.guilds[msg.guild.id].prefix;
const args = msg.content.slice(prefix.length).split(" ");

View File

@ -96,7 +96,7 @@ module.exports = {
noResults: emojis.redx + "I could not obtain any search results!",
noResultsLyrics: emojis.redx + "I could not obtain any results!",
noResultsSpotify: emojis.redx +
"I could not obtain any results! Make sure you have a key set! More info with the setkey setting.",
"I could not obtain any results!",
noServerQueue: emojis.redx + "There is nothing playing!",
noSongs: emojis.redx + "That song does not exist!",
notPremium: emojis.redx + "This is not a premium guild!",
@ -141,7 +141,6 @@ module.exports = {
seekingPointPositive: emojis.redx + "The seeking point needs to be a positive number!",
seekMax: emojis.redx +
"The lenght of this song is %LENGTH% seconds! You can't seek further than that!",
setKeyUsage: "Usage: `setkey <key> <guild id>`. Get your key from <https://developer.spotify.com/documentation/web-playback-sdk/quick-start/#> by pressing `Get your web playback sdk access token`.\nThe key will expire in 60 minutes!\nDO THIS COMMAND IN THE DMS! YOUR KEY IS PRIVATE DO NOT SHARE IT WITH ANYONE!",
settingsAnnounceSongs: "announcesongs",
settingsAnnounceSongsDesc: "Whether to announce songs that start playing or not.",
settingsBass: "bass",
@ -155,8 +154,6 @@ module.exports = {
settingsPrefixDesc: "Change the guild specific prefix. (string)",
settingsSetDj: "setdj",
settingsSetDjDesc: "Set a DJ role. This will allow chosen users to freely use all Musix commands. This will automatically set the `permissions` settings to true in order for the `DJ` role to have effect!",
settingsSetKey: "setkey",
settingsSetKeyDesc: "Get instructions on how to set a spotify key.",
settingsTitle: "Guild settings for Musix",
settingsVolume: "volume",
settingsVolumeDesc: "Change the default volume that the bot will start playing at. (number)",