maxcutlyp / YoutubeBot

A self-hosted Discord bot for playing YouTube videos
47 stars 26 forks source link

can't run code #10

Open yyurodd opened 1 year ago

yyurodd commented 1 year ago

I admit that the problem is most likely in me, but I've been trying to make / find a working bot for 5 hours now and I don't understand what the problem is

Traceback (most recent call last): File "C:\Users\petuk\Documents\stepik\youtubebot.py", line 29, in bot = commands.Bot(command_prefix=PREFIX, intents=discord.Intents(voice_states=True, guilds=True, guild_messages=True, message_content=True)) File "C:\Users\petuk\Documents\stepik\venv\lib\site-packages\discord\flags.py", line 402, in init raise TypeError('%r is not a valid flag name.' % key) TypeError: 'message_content' is not a valid flag name.

maxcutlyp commented 1 year ago

In your Discord developer portal, under the Bot tab in the sidebar, make sure you have "Message Content Intent" ticked on. image Otherwise, run pip show discord-py and let me know which version it is. It's possible that you have an outdated library, or that discord updated it quietly and removed/renamed the message_content intent.

yyurodd commented 1 year ago

Message content intent ticked on. изображение_2023-07-31_061041383

yyurodd commented 1 year ago

okay i just realized i have old discord-py. I just updated it and now i have this image

yyurodd commented 1 year ago

but i have a .env file with token image

maxcutlyp commented 1 year ago

That's weird. Maybe an issue with dotenv...? Try pip show python-dotenv.

yyurodd commented 1 year ago

image

yyurodd commented 1 year ago

just updated it but i still have this message, that's really weird because code returning this only if token is none but token definitely have a value

maxcutlyp commented 1 year ago

So pip show python-dotenv now says that it's on version 1.0.0?

For good measure, it might be worth running a quick pip install --upgrade -r requirements.txt. Also, what version of python are you running?

yyurodd commented 1 year ago

okay just solved the problem with token. out of habit, from old attempts, I also inserted the token into the code itself

yyurodd commented 1 year ago

and now i have new one :( Traceback (most recent call last): File "C:\Users\petuk\Documents\dsbot\venv\lib\site-packages\discord\client.py", line 441, in _run_event await coro(*args, *kwargs) File "C:\Users\petuk\Documents\dsbot\youtubebot.py", line 192, in on_command_error sp.run(['./restart']) File "C:\Users\petuk\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 505, in run with Popen(popenargs, **kwargs) as process: File "C:\Users\petuk\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in init self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Users\petuk\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, OSError: [WinError 193] %1 не является приложением Win32

yyurodd commented 1 year ago

"не является приложением" is meaning "is not an application". I don't know why it's written in Russian

yyurodd commented 1 year ago

the bot downloaded the video, entered the channel but did not play anything, then what I sent above was displayed

maxcutlyp commented 1 year ago

Looks like you need ffmpeg installed. The reason the error message is so cryptic is because the bot has a bash script to restart if it encounters an unknown error (since in production, that tends to fix things) - but Windows has no idea how to run bash, and throws a strange (apparently Russian) error.

To install ffmpeg, check out this guide that someone else linked in #6.

maxcutlyp commented 11 months ago

Hey @yyurodd - just wanted to check how you were going with this issue, did installing ffmpeg fix it?