1
0
mirror of https://github.com/musix-org/musix-oss synced 2025-06-16 12:36:01 +00:00

Fix code to work on this decade 1/x

This commit is contained in:
Christer Warén
2024-02-09 11:53:30 +02:00
parent d609687957
commit 9049a5e6b8
53 changed files with 2455 additions and 1704 deletions

View File

@ -1,5 +1,6 @@
const YouTube = require("simple-youtube-api");
const he = require('he');
const { EmbedBuilder, PermissionFlagsBits } = require("discord.js");
module.exports = {
name: 'playlist',
@ -7,43 +8,36 @@ module.exports = {
description: 'Save and load queues',
alias: 'pl',
cooldown: 10,
onlyDev: false,
async execute(message, args, client, Discord, prefix) {
const embed = new Discord.RichEmbed()
async execute(message, args, client, prefix) {
const embed = new EmbedBuilder()
.setTitle('Options for playlist!')
.addField('play', 'Play the guild specific queue.', true)
.addField('save', 'Save the currently playing queue. Note that this will overwrite the currently saved queue!', true)
.addField('add', 'Add songs to the playlist. Like song selection', true)
.addField('remove', 'Remove songs from the playlist.', true)
.addField('list', 'Display the playlist.', true)
.setFooter(`how to use: ${prefix}playlist <Option> <Optional option>`)
.setAuthor(client.user.username, client.user.displayAvatarURL)
.addFields(
{ name: 'play', value: 'Play the guild specific queue.', inline: true },
{ name: 'save', value: 'Save the currently playing queue. Note that this will overwrite the currently saved queue!', inline: true },
{ name: 'add', value: 'Add songs to the playlist. Like song selection', inline: true },
{ name: 'remove', value: 'Remove songs from the playlist.', inline: true },
{ name: 'list', value: 'Display the playlist.', inline: true }
)
.setFooter({ text: `how to use: ${prefix}playlist <Option> <Optional option>` })
.setAuthor({ name: client.user.username, iconURL: client.user.avatarURL()})
.setColor(client.config.embedColor)
const permissions = message.channel.permissionsFor(message.author);
if (message.author.id !== client.config.devId) {
if (client.global.db.guilds[message.guild.id].dj) {
if (!message.member.roles.has(client.global.db.guilds[message.guild.id].djrole)) return message.channel.send(':x: You need the `DJ` role to modify or play the playlist!');
} else if (!permissions.has('MANAGE_GUILD')) return message.channel.send(':x: You need the `MANAGE_SERVER` permission to modify the playlist!');
}
if (client.global.db.guilds[message.guild.id].dj) {
if (!message.member.roles.cache.has(client.global.db.guilds[message.guild.id].djrole)) return message.channel.send(':x: You need the `DJ` role to modify or play the playlist!');
} else if (!permissions.has(PermissionFlagsBits.ManageGuild)) return message.channel.send(':x: You need the `MANAGE_SERVER` permission to modify the playlist!');
if (client.global.db.guilds[message.guild.id].premium) {
if (args[1]) {
const optionName = args[1].toLowerCase();
const option = client.playlistCmd.get(optionName) || client.playlistCmd.find(cmd => cmd.aliases && cmd.aliases.includes(optionName));
if (!option) return message.channel.send(embed);
if (!option) return message.channel.send({ embeds: [embed] });
try {
option.execute(message, args, client, Discord, prefix);
option.execute(message, args, client, prefix);
} catch (error) {
message.reply(`:x: there was an error trying to execute that option! Please contact support with \`${prefix}bug\`!`);
const embed = new Discord.RichEmbed()
.setTitle(`Musix ${error.toString()}`)
.setDescription(error.stack.replace(/at /g, '**at **'))
.setColor(client.config.embedColor);
client.fetchUser(client.config.devId).then(user => user.send(embed)).catch(console.error);
client.channels.get(client.config.debug_channel).send(embed);
message.reply(`:x: there was an error trying to execute that option!`);
console.log(error);
}
} else {
return message.channel.send(embed);
return message.channel.send({ embeds: [embed] });
}
} else return message.channel.send(":x: This is not a premium guild!");
},