From a55ef4e455debacf9bc60becd2921530fcad8110 Mon Sep 17 00:00:00 2001 From: Nanotect <61177761+Adivise@users.noreply.github.com> Date: Mon, 7 Mar 2022 11:34:14 +0700 Subject: [PATCH] `Fix` Duplicate track! --- commands/playlist/create.js | 18 +++++++++--------- slashcommands/playlist/create.js | 14 +++++++------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/commands/playlist/create.js b/commands/playlist/create.js index 5d351d6..0eecfc3 100644 --- a/commands/playlist/create.js +++ b/commands/playlist/create.js @@ -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 @@ -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, diff --git a/slashcommands/playlist/create.js b/slashcommands/playlist/create.js index f19df26..9830d76 100644 --- a/slashcommands/playlist/create.js +++ b/slashcommands/playlist/create.js @@ -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]); } @@ -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,