Create a Discord Music Bot [Python]

preview_player
Показать описание
Today we'll be making a Discord music bot that plays audio from YouTube videos! It's a long ride to get this going, so be sure to grab a coffee and strap in for this video.

**DISCLAIMER**
This video is for educational purposes ONLY. Anything produced by this video should respect YouTube guidelines on streaming and downloading videos. Bots made using this content are not to be distributed, both non-commercially and commercially.

Timeline:
00:00 Building the bot on Discord
01:46 Setting up for the code
02:05 Downloading FFmpeg
02:30 Setting FFmpeg path as environment variable
03:39 Install required packages
04:50 Set up run_bot()
04:54 Load .env variables
05:12 Discussing .env
06:45 Setting up variables
08:44 Setting up on_ready()
09:00 Setting up on_message()
09:15 Setting up ?play command
13:12 First error
13:42 First successful test
14:15 Adding ?pause command and others
15:30 Second successful test
15:55 Outro
Рекомендации по теме
Комментарии
Автор

Man, you really saved me with this tutorial! You explain everything very well. Apparently, the only error I had was that I needed to install "pip install PyNaCl". Other than that, everything worked perfectly. Thank you for the video! I'm Brazilian and I loved your video. I hope you have more success!

cauaribeiro
Автор

great tutorial! thanks for giving me the foundation of my own bot. Also you are a pretty funny guy lol made the video even better with your personality. keep it up!

ryanm
Автор

Great video, good and simple explanation. congrats!

Samuel-pczv
Автор

Excellent stuff. I ran into 2 errors, which I can see others hitting as well.
1) My path environment didn't want to update until I restarted my computer. I'm on Windows.
2) I needed to install the library pynacl, as my bot couldn't join the voice channel and ffmepg was stalling out.

aaroncraig-kgwx
Автор

LoginFailure: Improper token has been passed.

Ksavzx
Автор

Nice video, man.
it would be nice if you make a video implementing a music queue.

alke
Автор

Thank you so much! I was having some trouble with some stuff and you helped a lot!

Ah, I wanted to add some slash commands. But it was pretty hard to sync with discord. Do you perhaps have a video about it?

Anyway, thanks a lot!

Phoenix
Автор

Im having a problem with yt_dlp, the import command isn't recognizing it.
The error is: "reportMissingImports"

And I already downloaded yt_dlp but it still doesn't work

jguivianna-
Автор

Thank you so much on the tutorial! I successfully created my bot.
However, I want this bot to be able to add a song in the queue when I use ?play twice or more, and it will automatically play the next song.
Can you advice me on how to do this? Even better if you make a tutorial about that.

izumi
Автор

Hi, thanks but I have this error :
AttributeError: 'FFmpegOpusAudio' object has no attribute '_process'

TheFrenchSalmon
Автор

Everythings works except for when the bot joins the channel no music is played... what could be causing this issue? Thank you for this tutorial btw

slavic_fox
Автор

Bro can u please create a tutorial on a music bot which searches music from the given text on spotify and other platforms. (Please create the text one so that people can use the music bot easily please bro)

Creative-Destruction
Автор

Hello friend, sorry, I'm new to programming. I have a problem: I can't get my bot online. What can I do?

jefreeyrendon
Автор

Hello, thank u so much for this tutorial but i have a problem :

My bot doesn’t come in the voice channel, do you know why ?
( btw there is no error message in the terminal)

Stationnn
Автор

This is one of the two bots I have been trying to research making. I saw you are going to make an updated version of this with a queue and slash command so I look forward to that, is there anyway you can make a video about a chatgpt bot? Every video I find in python is outdated and doesn't work. Thanks!

zacharyRL
Автор

if I use a raspberry pi to launch the bot, where do I have to put ffmpeg to use it?

hirotv
Автор

In this piece of code you can see that I don't have any errors, but my bot still joins the voice channel but I don't hear it, what could it be?

@client.event
async def on_message(msg):
if
try:
voice_client = await
= voice_client
except Exception as e:
print("error")

JhonDaid_JD
Автор

Am I just bad at following a tutorial or what? I get to the part at install packages and my terminal (using Pycharm) then says this error

pip : The term 'pip' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ pip install --asyncio
+ ~~~
+ CategoryInfo : ObjectNotFound: (pip:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

What do I even do??

josephsalazar
Автор

keep getting the errors:
ffmpeg process 10260 has not terminated. Waiting to terminate...
ffmpeg process 10260 should have terminated with a return code of -9.

how do i fix this?

victoriachoi
Автор

I'm having trouble with the code, especially with ffmpeg. Everything else is working fine, but when I try to play a song, it keeps saying "ffmpeg not found."

apotato