- Saved searches
- Use saved searches to filter your results more quickly
- License
- Darkempire78/Music-Discord-Bot
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- Как сделать музыкального бота в Discord?
- Saved searches
- Use saved searches to filter your results more quickly
- License
- Dysta/JukeBot
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
A music Discord bot with more than 30+ commands which allows to play music on your server efficiently. Supports Youtube, Spotify, Deezer and Soundcloud links. Skips intros and blanks in the music with Sponsorblock.
License
Darkempire78/Music-Discord-Bot
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Include fixes of pull request #1 while still maintaining index checking.
Git stats
Files
Failed to load latest commit information.
README.md
A Discord bot with more than 30+ commands which allows to play music on your server efficiently. Supports Youtube, Spotify, Deezer and Soundcloud links. Skips intros and blanks in the music with Sponsorblock (optional).
- create a discord application / bot here
- Install all dependencies : pip install -r requirements.txt .
- Download Lavalink.
- Install Java 11+
- Create a MySQL database and use the Scripts/generateDatabase.sql file to create the table.
- Edit configuration example.json :
"token": "", // Your bot token "prefix": "?", // Your prefix "playlistLimit": "15", // Optional - Defaults to 15 if not provided 0 is unlimited "sponsorblock": true, // True if you want to skip intros and blanks in the music // Spotify => https://developer.spotify.com/dashboard/ "spotifyClientId": "", // Your Spotify ID (OPTIONAL : Spotify links support) "spotifyClientSecret": "", // Your Spotify secret (OPTIONAL : Spotify links support) "MySQLHost": "", // Your MySQL host "MySQLLogin": "", // Your MySQL login "MySQLPasword": "", // Your MySQL password "MySQLDatabase": "" // Your MySQL database >
Finally, host the bot and invite it to your own server.
- Run Lavalink.jar (from Lavalink) with java -jar Lavalink.jar
- Note: you will likely want to use a config file in the same directory as Lavalink.jar to control its settings
- skip all but the first installation steps above
- install docker
- install docker-compose
- copy the configuration.docker.json file to ./configuration.json
- fill in your discord bot token
- optionally the spotify client id/secret && dbl tokens
Note: In theory you can skip docker-compose up -d db and just run docker-compose up -d but the timing of the db startup and running of the generateDatabase.sql on initial startup can sometimes cause the music bot to fail to start so its best to just start the db first to give it enough time
Docker running / debugging tips
- you can run docker-compose logs to view logs for all services
- you can run docker-compose logs eg: docker-compose logs musicbot to see the logs for a specific service (look in the compose file for the service names)
- you can run docker-compose stop to stop the music bot / db / lavalink containers
- you can run docker-compose start to start the music bot / db / lavalink after stopping
- Play music from YouTube
- Support links from YouTube, Spotify, Deezer and Soudcloud
- Support YouTube lives
- Support playlists from Spotify, Deezer, Soundcloud and YouTube
- Playlist system
- Sponsorblock integration to skip intros and blanks in the music
- Many commands
- Complex queue commands
?play : Search on youtube and play the music. ?search : Search a song on youtube. ?nowplaying : Display data about the current song. ?join : Add the bot to your voice channel. ?leave : Remove the bot of your voice channel. ?pause : Pause the current song. ?resume : Resume the current song. ?volume : Change the bot's volume. ?queue : Display the queue. ?shuffle : Shuffle the queue. ?move : Move a song in the queue. ?remove : Remove the song with its index. ?removedupes : Remove all duplicates song from the queue. ?leavecleanup : Remove absent user's songs from the queue. ?clear : Clear the queue. ?replay : Replay the current song. ?reload : Reload the current song. ?loop : Enable or disable the loop mode. ?loopqueue : Enable or disable the loop queue mode. ?playlist add : Add a track to your playlist. ?playlist remove : Remove a track to your playlist. ?playlist display : Display playlist's songs. ?playlist load : Add the whole playlist to the queue. ?stats : Display the bot's stats. ?support : Give a link to join the support server. ?invite : Give a link to invite the bot. ?vote : Give the Top.gg link to vote for the bot. ?help : Display the help. ?logout : Stop the bot process.
Как сделать музыкального бота в Discord?
Сразу извиняюсь, если вопрос глупый, но я не могу понять из-за чего эта ошибка. Сам бот заходит в голосовой канал и подсвечивает, т.е. работает, но ничего не слышно.
import asyncio import discord import youtube_dl from discord.ext import commands # Suppress noise about console usage from errors youtube_dl.utils.bug_reports_message = lambda: '' ytdl_format_options = < 'format': 'bestaudio/best', 'outtmpl': '%(extractor)s-%(id)s-%(title)s.%(ext)s', 'restrictfilenames': True, 'noplaylist': True, 'nocheckcertificate': True, 'ignoreerrors': False, 'logtostderr': False, 'quiet': True, 'no_warnings': True, 'default_search': 'auto', 'source_address': '0.0.0.0' # bind to ipv4 since ipv6 addresses cause issues sometimes >ffmpeg_options = < 'options': '-vn' >ytdl = youtube_dl.YoutubeDL(ytdl_format_options) class YTDLSource(discord.PCMVolumeTransformer): def __init__(self, source, *, data, volume=0.5): super().__init__(source, volume) self.data = data self.title = data.get('title') self.url = data.get('url') @classmethod async def from_url(cls, url, *, loop=None, stream=False): loop = loop or asyncio.get_event_loop() data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=not stream)) if 'entries' in data: # take first item from a playlist data = data['entries'][0] filename = data['url'] if stream else ytdl.prepare_filename(data) return cls(discord.FFmpegPCMAudio(filename, **ffmpeg_options), data=data) class Music(commands.Cog): def __init__(self, bot): self.bot = bot @commands.command() async def join(self, ctx, *, channel: discord.VoiceChannel): """Joins a voice channel""" if ctx.voice_client is not None: return await ctx.voice_client.move_to(channel) await channel.connect() @commands.command() async def play(self, ctx, *, query): """Plays a file from the local filesystem""" source = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(query)) ctx.voice_client.play(source, after=lambda e: print('Player error: %s' % e) if e else None) await ctx.send('Now playing: <>'.format(query)) @commands.command() async def yt(self, ctx, *, url): """Plays from a url (almost anything youtube_dl supports)""" async with ctx.typing(): player = await YTDLSource.from_url(url, loop=self.bot.loop, stream=True) ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None) await ctx.send('Now playing: <>'.format(player.title)) @commands.command() async def stream(self, ctx, *, url): """Streams from a url (same as yt, but doesn't predownload)""" async with ctx.typing(): player = await YTDLSource.from_url(url, loop=self.bot.loop, stream=True) ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None) await ctx.send('Now playing: <>'.format(player.title)) @commands.command() async def volume(self, ctx, volume: int): """Changes the player's volume""" if ctx.voice_client is None: return await ctx.send("Not connected to a voice channel.") ctx.voice_client.source.volume = volume / 100 await ctx.send("Changed volume to <>%".format(volume)) @commands.command() async def stop(self, ctx): """Stops and disconnects the bot from voice""" await ctx.voice_client.disconnect() @play.before_invoke @yt.before_invoke @stream.before_invoke async def ensure_voice(self, ctx): if ctx.voice_client is None: if ctx.author.voice: await ctx.author.voice.channel.connect() else: await ctx.send("You are not connected to a voice channel.") raise commands.CommandError("Author not connected to a voice channel.") elif ctx.voice_client.is_playing(): ctx.voice_client.stop() def setup(client): client.add_cog(Music(client)) print('Music: activated')
Ignoring exception in command yt: Traceback (most recent call last): File "C:\Users\volva\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped ret = await coro(*args, **kwargs) File "C:\Users\volva\Desktop\botTest\cogs\music.py", line 82, in yt player = await YTDLSource.from_url(url, loop=self.bot.loop, stream=True) File "C:\Users\volva\Desktop\botTest\cogs\music.py", line 52, in from_url return cls(discord.FFmpegPCMAudio(filename, **ffmpeg_options), data=data) File "C:\Users\volva\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\player.py", line 225, in __init__ super().__init__(source, executable=executable, args=args, **subprocess_kwargs) File "C:\Users\volva\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\player.py", line 138, in __init__ self._process = self._spawn_process(args, **kwargs) File "C:\Users\volva\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\player.py", line 147, in _spawn_process raise ClientException(executable + ' was not found.') from None discord.errors.ClientException: ffmpeg was not found. The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Users\volva\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke await ctx.command.invoke(ctx) File "C:\Users\volva\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke await injected(*ctx.args, **ctx.kwargs) File "C:\Users\volva\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ClientException: ffmpeg was not found.
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Discord music bot written in Python 3
License
Dysta/JukeBot
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Discord music bot written in Python 3
git clone https://github.com/Dysta/JukeBot cd JukeBot poetry install
Rename .env.example to .env and fill in the values.
Run poetry run task start .
Use the package manager Chocolatey and run in an admin shell choco install ffmpeg .
Use apt, run sudo apt install ffmpeg .
Use brew, run brew install ffmpeg .
Clone the repos.
Rename .env.example to .env and fill in the values.
Run docker-compose up -d .C/C the file .env.example in local, fill in the values.
Run docker run —env-file dysta/jukebot .Clone the project then open it in vscode . If you have the devcontainer extension, it will ask you to reopen the project in a devcontainer. If not, open the commands prompt then search for reopen in container.
All the needs will be automatically installed.