This is my latest own project around creating Discord bot music from scratch.
This repository is a bit unstable, including the loop command, etc. However, the rest of it is fine. I will gradually fix any issues and add more features to it.
I have a few friends who were hanging out, but they couldn't find a single functional Discord music bot for YouTube.
We've tried Uzox, Hydra, MEE6, Jockie Bot, and others alike, but none of them are working.
I was disappointed and said, you know what, F- it.
I've attempted to create my own Discord music bot from scratch, aiming for simplicity and ease of use.
I use:
- oceanic for the Discord library.
- ytdl-core and yt-search for retrieving YouTube contents.
- @discordjs/voice for Discord voice state management.
- ffmpeg for video/audio management.
- libmp3lame to encode video to mp3, helped with
ffmpeg
. - soundcloud-downloader for retrieving SoundCloud contents.
- Fork the repo.
npm install
first.pnpm
andyarn
works too, I mainly usepnpm
.- This repo uses
ffmpeg
, so please install them first.- Search Google on how to install
ffmpeg
on Ubuntu, Windows, or any.
- Search Google on how to install
- Rename
.env.example
to.env
, edit the configuration first, such as Discord bot token, etc.- You can edit the
Config.ts
file as well.
- You can edit the
- Run
npm run dev
for testing, andnpm run prod
for production.
I extended this project with more features, such as:
- Supports YouTube, that's obvious.
- Supports search mode using Discord dropdown component, by using
/play search-mode: true
- Supports playing contents from the playlist.
- Supports SoundCloud.
- Supports TikTok.
- Supports Spotify URL -> YouTube
- This means, you are able to use Spotify URL to get the track information and find that track from YouTube.
- Supports playing with .mp3 file.
- Supports playing with .mp4 file.
- Supports age-restriction bypass (YouTube platform only)
- Supports application/octet-stream.
- For example, converting video from TikTok to audio, and then copy the URL.
- Tested URL from ssstik.io, savefrom.net, fdown.net
- For example, converting video from TikTok to audio, and then copy the URL.
- Auto-disconnect when no one's in voice channel.
- Auto-retry if error occurred, especially 403 error from ytdl-core.
- Clutter-free.
- Yes, this project uses 100% slash commands and it's completely ephemeral/private.
Yes, there are bugs in this repository, but they weren't caused by me, I swear.
And, these bugs can be temporarily fixed by restarting the instance.
- Sometimes, pause command doesn't pause the music.
- TikTok remains unplayable after few plays.
- Sometimes,
ytdl
doesn't play anything at all.
Yeah, sure. I don't mind. You can recreate your own command handler, do your things here.
I'm just hoping that you put me on credit when you're using this commercially or vice-versa. ;<