Skip to content
← Back to Community
🎹 Discord Music Bots Native Support 🥁
Profile icon
h
has Hacker Plan
amasad

At Repl.it we believe programming should useful, fun, and exciting. Discord bots have been something people loved to make with Repl.it ever since we enabled outbound network connections from repls (yes, we used to disable networking).

music-02

Discord music bots, however, didn't work very well if at all. At first, OPUS was missing from our Python environment. Then we also inadvertently blocked voice connections from our servers. So all in all it was a pain. However, today, I'm excited to announce that Music Bots natively work on Repl.it.

The only thing that's currently missing from our images is native ffmpeg support, but that can be worked around by installing ffmpeg-static from npm. I just added the following Python repl to templates to make it easy for you to get started.

I know it works in Node.js too but I didn't have the time to make a nice template. If anyone can make a very simple template for Node.js I'd love to include it in our template library.

Voters
Profile icon
noobn00b13
Profile icon
HamidGame
Profile icon
PROneDevil
Profile icon
MohanadGalal
Profile icon
JohanM1
Profile icon
OlandezuOlande1
Profile icon
KendeTamas
Profile icon
RithvikSaiGopal
Profile icon
Tryponwtf
Profile icon
LANZi
Comments
hotnewtop
Profile icon
MarcoFX

I don't understand. What are the commands? Someone pleaase tell me.

Profile icon
iamujy

@MarcoFX its 'music.' followed by commands like play, pause, join, etc.

Profile icon
ChandralathaKan

why i getting this error

"An error occurred: Command raised an exception: DownloadError: ERROR: Xx9V0fTDJY0: YouTube said: Unable to extract video data"

Profile icon
Mckael123

@ChandralathaKan me to, pls help @amasad

Profile icon
lucasmellolm

@ChandralathaKan and @Mckael123
Use this command in shell terminal: pip install -U youtube-dl

Profile icon
GinkuiMain

@lucasmellolm mine uninstalls the new version and decides to use the previous one for some reason

Profile icon
BlazeAnnex

my bot gives me a error saying 'An error occurred: Command raised an exception: RuntimeError: PyNaCl library needed in order to use voice' isnt pynaci downloaded already?

Profile icon
taj0023

@BlazeAnnex Did u find a solution for this problem??? if so pls reply :)

Profile icon
BlazeAnnex

@taj0023 yeah i did it was pretty easy tbh go to packages side and search PyNaCl and then download it and youre done

Profile icon
taj0023

@BlazeAnnex AAAAAHHHH TYSM BRUH........

Profile icon
SolarK

@BlazeAnnex i know im late but how do you download it i are have stupid

Profile icon
SavageGamers99Y

@BlazeAnnex how do u download pls

Profile icon
SamirKhanGT

@BlazeAnnex you need to download pynacl again from packages

Profile icon
instrogamer121

@BlazeAnnex Ayo bro, your a life safer

Profile icon
jai789jai

List the commands for the bot.

Profile icon
DillonB07

@jai789jai music.help

Profile icon
ThijsFr

where can i find the website it doesn't generate a link or smthing

Profile icon
Poked

Is there a way to add Spotify to the bot?

Profile icon
buzzlightyear14

one issue
An error occurred: Command raised an exception: DownloadError: ERROR: iI34LYmJ1Fs: YouTube said: Unable to extract video data

Profile icon
Yoplayer1py

@buzzlightyear14 Use this command in shell terminal: pip install -U youtube-dl

Profile icon
burgerkingwhopp

for people who dont know the prefix, it's "music." you can change this by going to: bot = commands.Bot('music.', description='Yet another music bot.')
bot.add_cog(Music(bot))
and changing 'music.' to whatever prefix you want it to be

Profile icon
NilsoTheCookieMonster

@burgerkingwhopp
where in the code is that line?
i cant seem to find it

Profile icon
sankalprocks02

@AnakinSteve
last or second last line, near the end

Profile icon
Alvinzzzzz

When the bot tried to play the next song it raises this error

Traceback (most recent call last): File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/player.py", line 598, in run self._do_run() File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/player.py", line 585, in _do_run data = self.source.read() File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/player.py", line 538, in read ret = self.original.read() File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/player.py", line 223, in read ret = self._stdout.read(OpusEncoder.FRAME_SIZE) AttributeError: 'NoneType' object has no attribute 'read' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/player.py", line 611, in _call_after self.after(error) File "main.py", line 393, in play_next_song raise VoiceError(str(error)) VoiceError: 'NoneType' object has no attribute 'read'
Profile icon
DaliaAlJumaili

@Alvinzzzzz
same error, id love to get an answer on how to fix this

Profile icon
xxpertHacker

With native OPUS, networking, and native always up Repls... Repl might just be suitable for hosting a powerful bot.

Profile icon
HackermonDev

@xxpertHacker It might be able to host a small bot (a bot in like 20 servers) but it can't host big bots (a bot in like 200+ servers) because of memory and ram.

Profile icon
xxpertHacker

@PDanielY Yeah, there's also that, I forgot.

Profile icon
firefish

@xxpertHacker Containers have limits. Don't push them.

Profile icon
amasad

@firefish I don't know, we run some production work on Repl.it on a single container and it serves lots of users. We also have a lot of big bots already hosted on repl.it.

I would try it. If your code is efficient it should work especially with the hacker plan.

In the future, we'll probably have to introduce an even bigger plan.

Profile icon
firefish

@amasad Ok, I might just try it... sound interesting to me! :)

Profile icon
xxpertHacker

@amasad @firefish The biggest problem with most bots hosted here is the actual code and language, usually, they're written in inefficient languages (ex: Python, JS), but what's worse is they're often set up in very inefficient ways.
If you set it up correctly, plan ahead, and know what you're doing, it can perform very well, but this applies even outside of Repl.it.

Profile icon
Typh-Volk

@amasad my bot has grown a lot and it's all on repl :D

Profile icon
NilsoTheCookieMonster

you guys need to upgrade the youtube_dl

Profile icon
DEATHITSELF

My bot gives me an error saying: An error occurred: Command raised an exception: DownloadError: ERROR: query "Godzilla": Failed to parse JSON (caused by JSONDecodeError('Expecting value: line 1 column 1 (char 0)'))

Profile icon
CubingOP
Profile icon
followrel

@DEATHITSELF Do someone know, how to fix it?

Profile icon
cyrahaerin

have you figured out how to fix it??
@CubingOP

Profile icon
NilsoTheCookieMonster

@cyrahaerin
run this command in the shell
pip install --upgrade youtube_dl

Profile icon
MarwanSafwat

@NilsoTheCookieMonster it replys with "command not found"

Profile icon
CoolCoderz133

What is the prefix to this bot? how do i use it?

Profile icon
Dhaloi

@CoolCoderz133 example: music.play

Profile icon
AndrewC4289

What is the prefix

Profile icon
Typh-Volk

how did you get the packages package-lock.json and package.json?

Profile icon
HackermonDev

Tried to create a discord bot to play music (https://repl.it/@PDanielY/EasygoingPlumHashmaps#index.js).

(node:482) UnhandledPromiseRejectionWarning: Error: FFmpeg/avconv not found! at Function.getInfo (/home/runner/EasygoingPlumHashmaps/node_modules/prism-media/src/core/FFmpeg.js:130:11) at Function.create (/home/runner/EasygoingPlumHashmaps/node_modules/prism-media/src/core/FFmpeg.js:143:38) at new FFmpeg (/home/runner/EasygoingPlumHashmaps/node_modules/prism-media/src/core/FFmpeg.js:44:27) at AudioPlayer.playUnknown (/home/runner/EasygoingPlumHashmaps/node_modules/discord.js/src/client/voice/player/BasePlayer.js:47:20) at VoiceConnection.play (/home/runner/EasygoingPlumHashmaps/node_modules/discord.js/src/client/voice/util/PlayInterface.js:71:28) at startPlaying (/home/runner/EasygoingPlumHashmaps/index.js:12:14) at runMicrotasks (<anonymous>) at processTicksAndRejections (internal/process/task_queues.js:97:5)
Profile icon
HackermonDev

@PDanielY oh wait, i forgot to install ffmpeg-static but i fixed it. so nodejs template: https://repl.it/@PDanielY/discord-music-bot-template

Profile icon
EzekielCase

what does "the website made for your repl" in the markdown instructions mean? Is that the link to the code on repl or is it something else?

Profile icon
Huyexe

Replit: Package operation failed. WHY

image

Profile icon
DarkNinja3

how do i make a javascript music bot with this?

Profile icon
LANZi

Even if I changed the name to keep_alive() no website URL appears when I run it

Profile icon
ri608la0

i get the error package operation failed any help?

Profile icon
GinkuiMain

The bot simply doesn't work for me..
Tried using Music, Music. music and music.

it simply doesn't work! help me pls

Profile icon
EVIL-SHADOWSHAD

Im getting any error of exit status 1 what it mean

Profile icon
stevensanders12

I am a music lover and love breakthrough ideas in music. I really like what you have shared. This will help with my phone dzwonki mp3 idea.

Profile icon
GoldenFright100

Is there a line of code that i cna change the skip so that there has to be no votes to skip a song regardless of who requested the song?

Profile icon
BurninBush

it gives me an "exit status 1" how do i fix this?

Profile icon
instrogamer121

How to make the bot a .mp3 file? What I mean is that I upload a .mp3 file from my computer, and before I send it, I put in the command and send it, after sending the .mp3 file, the bot will play the song (if it is in a channel with the person who sent the .mp3 file with the command)

Profile icon
OneZeroOneZeroL

photo_2021-10-21_17-19-17

ayup, can someone explain this problem and how to fix it?

Profile icon
OneZeroOneZeroL

This file cannot be displayed:

Profile icon
OneZeroOneZeroL

File "main.py", line 240, in play_next_song
raise VoiceError(str(error))
VoiceError: 'NoneType' object has no attribute 'read'