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

[YOUTUBEJS][Text]: Unable to find matching run for command run. Skipping... #33

Closed
2 tasks done
lexusdev2 opened this issue Jan 1, 2025 · 6 comments
Closed
2 tasks done
Labels
bug Something isn't working

Comments

@lexusdev2
Copy link

lexusdev2 commented Jan 1, 2025

Before you report a bug ...

  • I have checked that I am on the latest version of discord-player-youtubei
  • I have checked existing issues to see if this is a duplicate report

Description of the bug

When you type the command, and look on command prompt, it says this [YOUTUBEJS][Text]: Unable to find matching run for command run. Skipping...

Steps to reproduce

  1. Turn on the bot
  2. Type the command play

Screenshot(s)

image

Versioning

discord-player: latest
node.js: 22.12.0

const { EmbedBuilder, ApplicationCommandOptionType, PermissionsBitField } = require('discord.js');
const { QueryType, useMainPlayer } = require('discord-player');

module.exports = {
    name: 'play',
    description: 'Loads songs from YouTube',
    type: ApplicationCommandOptionType.String,
    options: [
        {
            name: 'song',
            description: 'Loads a single song from a URL',
            type: ApplicationCommandOptionType.Subcommand,
            options: [
                {
                    name: 'name',
                    description: 'The song name',
                    type: ApplicationCommandOptionType.String,
                    required: true
                }
            ]
        },
        {
            name: 'playlist',
            description: 'Loads a playlist from a URL',
            type: ApplicationCommandOptionType.Subcommand,
            options: [
                {
                    name: 'playlist-url',
                    description: 'The playlist URL',
                    type: ApplicationCommandOptionType.String,
                    required: true
                }
            ]
        },
        {
            name: 'search',
            description: 'Searches for a song based on provided keywords',
            type: ApplicationCommandOptionType.Subcommand,
            options: [
                {
                    name: 'searchterms',
                    description: 'Search keywords',
                    type: ApplicationCommandOptionType.String,
                    required: true
                }
            ]
        }
    ],
    callback: async (client, interaction) => {
        await interaction.deferReply();
        const player = useMainPlayer(client);
        const voiceChannel = interaction.member.voice.channel;

        if (!voiceChannel) return interaction.editReply('You need to be in a voice channel to play music!');
        if (interaction.guild.members.me.voice.channel && interaction.guild.members.me.voice.channel !== voiceChannel)
            return interaction.editReply('I am already playing in a different voice channel!');
        if (!interaction.guild.members.me.permissions.has(PermissionsBitField.Flags.Connect))
            return interaction.editReply('I do not have permission to join your voice channel!');
        if (!interaction.guild.members.me.permissionsIn(voiceChannel).has(PermissionsBitField.Flags.Speak))
            return interaction.editReply('I do not have permission to speak in your voice channel!');

        let queue = player.nodes.get(interaction.guild.id);

        if (!queue) {
            queue = await player.nodes.create(interaction.guild, {
                metadata: {
                    channel: interaction.channel,
                },
                volume: 100,
                leaveOnEnd: false,
                leaveOnStop: false,
            });
            await queue.connect(voiceChannel);
        }

        const embed = new EmbedBuilder()
            .setColor("#2B2D31");

        try {
            if (interaction.options.getSubcommand() === "song") {
                let name = interaction.options.getString("name");
                const result = await player.search(name, {
                    requestedBy: interaction.user,
                    searchEngine: QueryType.AUTO
                });

                if (!result || result.tracks.length === 0)
                    return interaction.editReply({
                        embeds: [embed.setTitle('NOT FOUND').setDescription('No song found with that title.')]
                    });

                const song = result.tracks[0];
                await queue.addTrack(song);
                embed.setTitle('SONG ADDED TO QUEUE').setDescription(`**[${song.title}](${song.url})** has been added to the queue.`).setThumbnail(song.thumbnail).setFooter({ text: `Duration: ${song.duration}` });

            } else if (interaction.options.getSubcommand() === "playlist") {
                let url = interaction.options.getString("playlist-url");
                const result = await player.search(url, {
                    requestedBy: interaction.user,
                    searchEngine: QueryType.YOUTUBE_PLAYLIST
                });

                if (!result || result.tracks.length === 0)
                    return interaction.editReply({
                        embeds: [embed.setTitle('NO PLAYLIST').setDescription('No playlist found.')],
                    });

                const playlist = result.playlist;
                await queue.addTracks(result.tracks);
                embed.setDescription(`**${result.tracks.length} songs from [${playlist.title}](${playlist.url})** have been added to the queue.`).setThumbnail(playlist.thumbnail);

            } else if (interaction.options.getSubcommand() === "search") {
                let searchterms = interaction.options.getString("searchterms");
                const result = await player.search(searchterms, {
                    requestedBy: interaction.user,
                    searchEngine: QueryType.AUTO
                });

                if (!result || result.tracks.length === 0)
                    return interaction.editReply({
                        embeds: [embed.setTitle('NO RESULT').setDescription('No results found for the search terms.')],
                    });

                const song = result.tracks[0];
                await queue.addTrack(song);
                embed.setTitle('SONG ADDED TO QUEUE').setDescription(`**[${song.title}](${song.url})** has been added to the queue.`).setThumbnail(song.thumbnail).setFooter({ text: `Duration: ${song.duration}` });
            }

            if (!queue.playing) await queue.play();

            await interaction.editReply({
                embeds: [embed]
            });
        } catch (error) {
            embed.setTitle('ERROR').setDescription('An unexpected error occurred. Please try again.');
            await interaction.editReply({ embeds: [embed] });
        }
    }
};
@lexusdev2 lexusdev2 added the bug Something isn't working label Jan 1, 2025
@retrouser955
Copy link
Owner

Does stream extraction and metadata querying work?

@lexusdev2
Copy link
Author

Does stream extraction and metadata querying work?

do you mean this?
image
Sorry, I don't understand what you meant, I'm sorry

@retrouser955
Copy link
Owner

Do you get proper info and does songs work? @lexusdev2

@HalCroves
Copy link

HalCroves commented Jan 8, 2025

Hello, I'm commenting here because I am experiencing the same issue.

I am using the latest version of discord-player.js, and for the Node.js version, I am using v18.20.5.

As lexusdev2 mentioned, I encounter the same error when a track is added/played. However, I only encounter the error with tracks that are not from YouTube, such as those from Spotify or SoundCloud. There are no issues with retrieving track information (title, description, duration, etc.).

Usage example:

YouTube: !play https://www.youtube.com/watch?v=dQw4w9WgXcQ -> No error.
Spotify: !play or !add https://open.spotify.com/intl-fr/track/4eDYMhIin1pSLIG96f1aD0?si=b61205fb307041e1 -> Error.
SoundCloud: !play or !add Drose - No Ducking -> Error.

Error encountered:

[YOUTUBEJS][Text]: Unable to find matching run for command run. Skipping... {
  command_run: { startIndex: 0, length: 48, onTap: { innertubeCommand: [Object] } },
  input_data: {
    content: 'Drose - Lets Meet (Official Music Video) · 2:36',
    commandRuns: [ [Object] ]
  },
  parsed_runs: [
    {
      text: 'Drose - Lets Meet (Official Music Video) · 2:36',
      startIndex: 0
    }
  ]
}

Maybe fixed here : LuanRT/YouTube.js#854, LuanRT/YouTube.js#862, but no new version.

@lexusdev2
Copy link
Author

Do you get proper info and does songs work? @lexusdev2

no sir

@retrouser955
Copy link
Owner

I'm closing this due to inactivity. This is most likely a flagged IP issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants