SushiBtw / discord-music-player

Complete framework to facilitate music commands using discord.js v14 & v13.
https://discord-music-player.js.org/
MIT License
157 stars 65 forks source link

[BUG] Short bug description #331

Open B3ni15 opened 9 months ago

B3ni15 commented 9 months ago

Bug Description For some reason, it always says "client not defined" and I always get this error.

Reproduction Steps Steps to reproduce the behavior:

  1. start the bot

and error..

Expected Result Bot should start without error!

Attachments image image

My Command:

const { MessageEmbed } = require("discord.js");

const { Player } = require("discord-music-player");
const player = new Player(client, {
    leaveOnEmpty: false,
});;

module.exports = {
    name: "play",
    description: "Zene Lejátszása",
    category: "song",
    slash: true,
    options: [
        {
          name: "zene",
          description: "Zene linkje amit szeretnél leállítani!",
          type: "STRING",
          required: true,
        },
    ],
    global: true,
    error: async () => {},
    run: async (data) => {
        const zene = data.interaction.options.getString('zene');
        const voiceChannel = data.interaction.member.voice.channel;
        let queue = player.createQueue(data.interaction.guild.id);
        let guildQueue = player.getQueue(data.interaction.guild.id);

        if (!zene) {
            return data.interaction.reply("> Kérlek adj meg egy zenét!");
        }

        if (!voiceChannel) {
            return data.interaction.reply("> Legyél bent egy hangcsatornában!");
        }

        await queue.join(voiceChannel);
        let song = await queue.play(zene).catch(err => {
            console.log(err);
            if(!guildQueue)
                queue.stop();
        });

        const embed = new MessageEmbed()
            .setTitle(`Zene Lejátszása`)
            .setDescription(`> Beléptem a hangcsatornába és elkezdtem lejátszani a zenét!`)
            .setTimestamp()
            .addField("Zene:", queue.author, true)
            .addField("Hossz:", queue.duration, true)
            .addField("Link:", queue.url, true)
            .addField("Hozzáadta:", queue.requestedBy, true)
            .setThumbnail(queue.thumbnail)
            .setColor("#7289DA");

        data.interaction.editReply({
            embeds: [embed],
        });
    },
};

Versioning: