Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Player dead on the next play command #66

Open
Takiyo0 opened this issue Dec 26, 2024 · 1 comment
Open

[BUG] Player dead on the next play command #66

Takiyo0 opened this issue Dec 26, 2024 · 1 comment

Comments

@Takiyo0
Copy link
Owner

Takiyo0 commented Dec 26, 2024

          I do have the same problem right now, first song that is played will do fine.

Next time you restart everythings dead, getting the res array and the player is being created without a result to play.

Multiple Resolves: resolve Promise { ArrayBuffer { [Uint8Contents]: <>, byteLength: 0 } } undefined

const { channel } = interaction.member.voice;

            checkIntChannel(interaction, channel)

            const search = interaction.options.getString("search");

            const player = await client.manager.createPlayer({
                guildId: interaction.guild.id,
                textId: interaction.channel.id,
                voiceId: channel.id,
                volume: 50,
                deaf: true,
                shardId: interaction.guild.shardId,
            });

            const res = await player.search(search, { requester: interaction.user });

            if (!res.tracks.length) {
                const NoResultsEmb = new EmbedBuilder()
                    .setAuthor({
                        name: "No results found.",
                        iconURL: interaction.user.displayAvatarURL({ dynamic: true })
                    });

                return interaction.reply({ embeds: [NoResultsEmb], ephemeral: true });
            }

            if (res.type === "PLAYLIST") {
                for (let track of res.tracks) {
                    await player.queue.add(track);
                }
                if (!player.playing && !player.paused) {
                    player.play();
                }
            } else {
                await player.queue.add(res.tracks[0]);
                if (!player.playing && !player.paused) {
                    player.play();
                }
            }

            return interaction.reply({ content: `Added ${res.tracks[0].title} to the Queue.`, ephemeral: true });

        } catch (e) {
            await console.log("Error in play.js: " + e);
            if (!interaction.replied) {
                return interaction.reply({ content: "An error occurred while trying to play the song.", ephemeral: true });
            }
        }

Originally posted by @path1337 in #34 (comment)

@Takiyo0
Copy link
Owner Author

Takiyo0 commented Dec 26, 2024

sorry but what do you mean "Next time you restart everythings dead" ? is it the next time when you execute the play command?

does "getting the res array and the player is being created without a result to play." means the player is getting created, but there's no result to play, thus it's stuck? if yes, yoy should do put this code if (!player.queue.current && !player.queue.length) player.destroy(); when there's no result. for example in your case, it'll be

            if (!res.tracks.length) {
                const NoResultsEmb = new EmbedBuilder()
                    .setAuthor({
                        name: "No results found.",
                        iconURL: interaction.user.displayAvatarURL({ dynamic: true })
                    });
                if (!player.queue.current && !player.queue.length) player.destroy();
                return interaction.reply({ embeds: [NoResultsEmb], ephemeral: true });
            }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant