Skip to content
This repository has been archived by the owner on Sep 27, 2022. It is now read-only.

Commit

Permalink
Fix Duplicate track!
Browse files Browse the repository at this point in the history
  • Loading branch information
Adivise committed Mar 7, 2022
1 parent 9dc6df6 commit a55ef4e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
18 changes: 9 additions & 9 deletions commands/playlist/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,16 @@ module.exports = {

Playlist.findOne({ name: PlaylistName }).then(playlist => {
if(playlist) {
if(playlist.owner !== message.author.id) return message.channel.send(`${client.i18n.get(language, "playlist", "create_owner")}`);
const LimitTrack = playlist.tracks.length + TrackAdd.length; //You can't add more than ${client.config.LIMIT_TRACK} tracks to this playlist.
if(LimitTrack > client.config.LIMIT_TRACK) return message.channel.send(`${client.i18n.get(language, "playlist", "create_limit_track", {
if(playlist.owner !== message.author.id) { message.channel.send(`${client.i18n.get(language, "playlist", "create_owner")}`); TrackAdd.length = 0; return; }
const LimitTrack = playlist.tracks.length + TrackAdd.length;
if(LimitTrack > client.config.LIMIT_TRACK) { message.channel.send(`${client.i18n.get(language, "playlist", "create_limit_track", {
limit: client.config.LIMIT_TRACK
})}`);
})}`); TrackAdd.length = 0; return; }
for (let songs = 0; songs < TrackAdd.length; songs++) {
playlist.tracks.push(TrackAdd[songs]);
}
playlist.save().then(() => {
const embed = new MessageEmbed() //**Added • [\`${TrackAdd.length} track's\`] | Playlist • ${PlaylistName}**
const embed = new MessageEmbed()
.setDescription(`${client.i18n.get(language, "playlist", "create_added", {
count: TrackAdd.length,
playlist: PlaylistName
Expand All @@ -123,12 +123,12 @@ module.exports = {
}).catch(err => console.log(err));
}
else {
if(TrackAdd.length > client.config.LIMIT_TRACK) return message.channel.send(`${client.i18n.get(language, "playlist", "create_limit_track", {
if(TrackAdd.length > client.config.LIMIT_TRACK) { message.channel.send(`${client.i18n.get(language, "playlist", "create_limit_track", {
limit: client.config.LIMIT_TRACK
})}`);
if(LimitPlaylist >= client.config.LIMIT_PLAYLIST) return message.channel.send(`${client.i18n.get(language, "playlist", "create_limit_playlist", {
})}`); TrackAdd.length = 0; return; }
if(LimitPlaylist >= client.config.LIMIT_PLAYLIST) { message.channel.send(`${client.i18n.get(language, "playlist", "create_limit_playlist", {
limit: client.config.LIMIT_PLAYLIST
})}`);
})}`); TrackAdd.length = 0; return; }
const CreateNew = new Playlist({
name: PlaylistName,
owner: message.author.id,
Expand Down
14 changes: 7 additions & 7 deletions slashcommands/playlist/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ module.exports = {

Playlist.findOne({ name: PlaylistName }).then(playlist => {
if(playlist) {
if(playlist.owner !== interaction.user.id) return interaction.followUp(`${client.i18n.get(language, "playlist", "create_owner")}`);
if(playlist.owner !== interaction.user.id) { interaction.followUp(`${client.i18n.get(language, "playlist", "create_owner")}`); TrackAdd.length = 0; return; }
const LimitTrack = playlist.tracks.length + TrackAdd.length; //You can't add more than ${client.config.LIMIT_TRACK} tracks to this playlist.
if(LimitTrack > client.config.LIMIT_TRACK) return interaction.followUp(`${client.i18n.get(language, "playlist", "create_limit_track", {
if(LimitTrack > client.config.LIMIT_TRACK) { interaction.followUp(`${client.i18n.get(language, "playlist", "create_limit_track", {
limit: client.config.LIMIT_TRACK
})}`);
})}`); TrackAdd.length = 0; return; }
for (let songs = 0; songs < TrackAdd.length; songs++) {
playlist.tracks.push(TrackAdd[songs]);
}
Expand All @@ -115,12 +115,12 @@ module.exports = {
}).catch(err => console.log(err));
}
else {
if(TrackAdd.length > client.config.LIMIT_TRACK) return interaction.followUp(`${client.i18n.get(language, "playlist", "create_limit_track", {
if(TrackAdd.length > client.config.LIMIT_TRACK) { interaction.followUp(`${client.i18n.get(language, "playlist", "create_limit_track", {
limit: client.config.LIMIT_TRACK
})}`);
if(LimitPlaylist >= client.config.LIMIT_PLAYLIST) return interaction.followUp(`${client.i18n.get(language, "playlist", "create_limit_playlist", {
})}`); TrackAdd.length = 0; return; }
if(LimitPlaylist >= client.config.LIMIT_PLAYLIST) { interaction.followUp(`${client.i18n.get(language, "playlist", "create_limit_playlist", {
limit: client.config.LIMIT_PLAYLIST
})}`);
})}`); TrackAdd.length = 0; return; }
const CreateNew = new Playlist({
name: PlaylistName,
owner: interaction.user.id,
Expand Down

0 comments on commit a55ef4e

Please sign in to comment.