Updates from the Repl.it team about the product

← Back to all posts
🎹 Discord Music Bots Native Support 🥁
amasad (3248)

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).

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.

ChandralathaKan (3)

why i getting this error

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

MarcoFX (3)

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

BlazeAnnex (5)

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?

taj0023 (0)

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

BlazeAnnex (5)

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

taj0023 (0)

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

YukiAD (1)

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

xxpertHacker (768)

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

HackermonDev (1989)

@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.

xxpertHacker (768)

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

firefish (931)

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

amasad (3248)

@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.

firefish (931)

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

xxpertHacker (768)

@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.

Eyseedoubleyou (25)

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


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)'))

CoolCoderz133 (2)

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

Dhaloi (4)

@CoolCoderz133 example: music.play <your youtube video link>

Eyseedoubleyou (25)

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

HackermonDev (1989)

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)
HackermonDev (1989)

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

Cioara0000 (0)

for me is not working, i tried to play a song, i add at the final
"bot = commands.Bot(command_prefix=("$"))
and i tried to play something with my prefix "$" and doesn't work, do i need to download the packages files that you post it here, or it doesn't matter?

jai789jai (0)

List the commands for the bot.

Scorpliet (0)

For those people confused with prefix
you can add it yourselves too
in the line:
bot = commands.Bot('music.', description='Yet another music bot.')
change it to
bot = commands.Bot(command_prefix=("!"),'music.', description='Yet another music bot.')
Here the prefix i set was '!'

Alvinzzzzz (1)

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
  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
  File "main.py", line 393, in play_next_song
    raise VoiceError(str(error))
VoiceError: 'NoneType' object has no attribute 'read'
expensivesalt80 (0)

What is the prefix and how cna I change it


@expensivesalt80 From what I see the bot doesn’t have a prefix. To change it go to the bottom of the main.py code and find where it says bot = commands.Bot(‘music.’, description=‘Yet another music bot.’). Once you have found that change it to bot = commands.Bot(‘music.’, description=‘Yet another music bot.’, command_prefix = ‘yourprefix’). I hope this helps you and others that may see this message :)


The prefix is music.

Beau222 (0)

Does anyone know the prefix? I dont know what it is.

TylerFlowers (4)

Oh sweet! Finally! This is probably gonna be a nightmare to set up with my current bot, but I'm glad this is finally supported.

AndrewC4289 (0)

What is the prefix

Faresgmr (0)

it says improper token has been passed :'(

HahaYes (1900)

mosic shall overtake the world

Tea307307 (0)

where can i put the preflix in?

TheForArkLD (760)

thanks for merge,
and this is cool :D

stubaduble (13)

I am so confused.. how do you give your bot an actual purpose?

stubaduble (13)

@amasad what does the token mean?
Is it the id?

TonyCrafter (0)

@stubaduble Open Chrome, go to Discord Developer Portal and select your application. If you don't have one, create it. Then look for this tab. It's at your left.

Click Bots, and you'll see something like this.

Click Copy, and you're done.

TonyCrafter (0)

Oh, and you don't want to share it. People may have full access to your bot if you leak that token somewhere on the internet. Keep it safe!

MuriloBeluco (0)

my bot fails with the error "ffmpeg was not found"

amasad (3248)

@MuriloBeluco If you forked our template it should work. If you're starting from scratch make sure to

  • open shell and npm install ffmpeg-static
  • create a .replit file and in it put the following:
export PATH="$PWD/node_modules/ffmpeg-static:$PATH"
python main.py
amasad (3248)

@MuriloBeluco You should still use npm install because that's the easiest way to get ffmpeg right now.

We're in the process of adding it by default but for now follow the steps above.

DynamicSquid (4602)

Awesome! Wish you could make a bot using a C-Family language though...

xxpertHacker (768)

@DynamicSquid Why can't you? I've seen bots built with aegis.cpp.

firefish (931)

@DynamicSquid There's a thing called C++ embedding in nodejs, and you can also have full access to the raw V8 engine via that

dabs364 (276)

AttributeError: 'NoneType' object has no attribute 'strip'
exit status 1 @amasad

Anthony343434 (0)

@dabs364 i have the same error, except when i put my bots token in, it still says it...