JaBa/commands/Music/removeplaylist.js

42 lines
974 B
JavaScript
Raw Normal View History

2022-03-26 17:23:03 +05:00
const Command = require("../../base/Command");
class RemovePlaylist extends Command {
constructor(client) {
super(client, {
name: "removeplaylist",
dirname: __dirname,
enabled: true,
guildOnly: true,
aliases: ["rpl", "removepl"],
memberPermissions: [],
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"],
nsfw: false,
ownerOnly: false,
cooldown: 3000
});
}
async run(message, args, data) {
2022-03-28 23:02:30 +05:00
const name = args.join(" ");
2022-03-26 17:23:03 +05:00
if (!name) return message.error("music/createplaylist:NO_NAME");
const playlists = data.userData.playlists;
for (const playlist of playlists) {
2022-03-29 18:18:32 +05:00
if (!playlist.name === name) return message.error("music/removeplaylist:NOT_FOUND", {
name
});
2022-03-26 17:23:03 +05:00
2022-03-29 18:18:32 +05:00
const index = playlists.indexOf(playlist);
playlists.splice(index, 1);
2022-03-26 17:23:03 +05:00
2022-03-29 18:18:32 +05:00
data.userData.markModified("playlists");
data.userData.save();
message.success("music/removeplaylist:REMOVED", {
name
});
2022-03-26 17:23:03 +05:00
}
}
}
module.exports = RemovePlaylist;