question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: TypeError when playing a Youtube song with @discordx/music

See original GitHub issue

What happened?

When playing a song with Queue.play, nothing is played. Looking at the stacktrace, it seems like Queue.processQueue throws an error that’s caught and it tries to emit an error, and tries to index error.resource.metadata, but that causes an error (See below). The problem seems to be twofold: the song isn’t being played, and the error handling causes an error.

node version: 16.6.0 OS: Arch Linux (5.14.14-arch1-1)

If there is any other relevant information I should include, let me know.

Reproduction

Link to repo

To reproduce, paste in the bot token to bot_token, get the bot running and run ~test in a server while connected to a voice channel. Key file to look at are youtubePlayer.ts

Package

@discordx/music

Version

Stable

Relevant log output

➜  BananaBotJS yarn run start
yarn run v1.22.17
$ nodemon --exec BOT_TOKEN=`cat bot_token` node --loader ts-node/esm/transpile-only src/index.ts
[nodemon] 2.0.15
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: ts,json
[nodemon] starting `BOT_TOKEN=<omitted> node --loader ts-node/esm/transpile-only src/index.ts`
(node:2134137) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
BananaTesting >> global >> command >> adding 0 []
BananaTesting >> global >> command >> deleting 0 []
BananaTesting >> global >> command >> updating 0 []
Bot started
TypeError: Cannot read property 'metadata' of undefined
    at MyQueue.processQueue (file:///home/tony/repos/BananaBotJS/node_modules/@discordx/music/src/YoutubePlayer/core/Queue.ts:272:56)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
[nodemon] app crashed - waiting for file changes before starting...


### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
tonyd33commented, Dec 7, 2021

Thanks. I should have reached out on the discord server first; didn’t realize there was one. It might be helpful to reference the example in the music package’s README.

Alright, will add discord server link on all our package’s readme.

Ah sorry, my reply was confusing. I had meant adding the music bot example to the README, but that’s a good idea too

still confusing, the bot example link is on readme but of discordx package, did you mean for @discordx/music?

Yeah. As far as I could tell, I didn’t see any mention of it for @discordx/music previously but I see you just added it. Thanks.

1reaction
samarmeenacommented, Dec 6, 2021

in your repo, you need to move the Player object outside slash command. check music example for more details.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Discord.py music bot raising TypeError when a youtube link is ...
Try this out, it should work for both a YouTube song name and a YouTube URL: import asyncio import discord import youtube_dl from ......
Read more >
[BUG] Some Direct link youtube videos fail to play #274 - GitHub
Use play command with <some direct link to an age restricted video> . Error will be thrown and song will fail to play;...
Read more >
Rythm Discord Bot Not Working: Bug Fixed (2022) - YouTube
Rythm Discord Bot not working? Rythm not playing music ? Learn how to easily fix Rythm, and make the audio work again!
Read more >
Create a Music Discord Bot using Discord JS - YouTube
Create a music bot using JavaScript, discord JS, ffmpeg, youtube -dl and discord - player. I will guide you through the entire process...
Read more >
Discord JS - Playing Audio in a Voice Channel ... - YouTube
In this video we go over how to get your bot to join a voice channel and how to play an audio file...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found