An open API service indexing awesome lists of open source software.

https://github.com/cluena/mscbot


https://github.com/cluena/mscbot

discord-bot python

Last synced: 8 months ago
JSON representation

Awesome Lists containing this project

README

          

![MSCBOT](https://socialify.git.ci/clueNA/MSCBOT/image?font=KoHo&language=1&name=1&owner=1&pattern=Transparent&stargazers=1&theme=Dark)

# Discord Music Bot

A simple Discord bot to play music from YouTube, manage a queue, and control playback in voice channels.

## Features

- Play audio from YouTube URLs.
- Queue management (add, view, skip, clear).
- Control playback (pause, resume, stop).
- Join and leave voice channels automatically.

## Prerequisites

Before running the bot, make sure you have the following:

1. Python 3.8 or later.
2. The required Python packages:
- `discord.py`
- `yt-dlp`
- `python-dotenv`
- `PyNaCl`
- `ffmpeg` (installed on your system and added to PATH).

## Setup

1. Clone the repository or copy the script.
```bash
git clone https://github.com/clueNA/MSCBOT
```
3. Install the required dependencies:
```bash
pip install discord.py yt-dlp python-dotenv pynacl
```
4. Install `ffmpeg`:
- On Windows: Download from [FFmpeg](https://www.ffmpeg.org/) and add to PATH.
- On macOS: Use Homebrew: `brew install ffmpeg`.
- On Linux: Install via your package manager: `sudo apt install ffmpeg`.
5. Create a `.env` file in the project directory with your Discord bot token:
```bash
echo DISCORD_TOKEN=your_token_here > .env
```
6. Run the bot:
```bash
python music_bot.py
```
## Commands
### General Commands



Command
Description




!help
Show all available commands.


!join
Bot joins your voice channel.


!leave
Bot leaves the voice channel.

### Music Playback Commands



Command
Description




!play <url>
Play or queue audio from a YouTube URL.


!queue
Display the current queue.


!skip
Skip the currently playing song.


!np
Shows information about the currently playing track


!clear
Clear the queue.


!loop
Changes loop mode (off/track/queue).


!pause
Pause the current song.


!resume
Resume the paused song.


!stop
Stop playback and clear the queue.

## Example Usage
1. Join a voice channel.
2. Use `!play ` to start playing music.
3. Use `!queue` to view the current queue.
4. Manage playback with commands like `!skip` or `!pause`.

## Troubleshooting
- Error: "Could not extract video data"
- Ensure the YouTube URL is valid, and `yt-dlp` is installed and up-to-date.

- Bot does not join voice channel:
- Verify you are in a voice channel and the bot has permission to join.

- Bot does not respond:
- Ensure the bot is running, and the token in `.env` is correct.

## Acknowledgments
- `discord.py`: For Discord API integration.
- `yt-dlp`: For YouTube video and audio extraction.
- `FFmpeg`: For audio processing.
- `PyNaCl`: For voice support in discord.py.