Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
pondsan1412 committed Nov 11, 2023
1 parent ecf523f commit 92c02c3
Show file tree
Hide file tree
Showing 63 changed files with 35,176 additions and 1,113 deletions.
1 change: 1 addition & 0 deletions .cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"access_token": "BQB2JOzuo0VLdrdYihd6DWGugf65O0nS18Qmr6_AGXY9wvfrdH_KJQ_4oRpb-7_hy2O8JS7z3ZOrmjzaAQDTogcUNEiTZk0cLiZWHMwHNV2oW6p9u_Fl", "token_type": "Bearer", "expires_in": 3600, "expires_at": 1681772332}
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

- name: Build
run: >
pip install -r requirements.txt pyinstaller==5.12.0
pip install -r requirements.txt pyinstaller==5.8.0
&& python -m config.build
- name: Upload binaries to release
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ __pycache__
/dist

/config.json
/config/config_comments.json
/settings.db
/log.txt
config/config.py
config/config.py
config/config.py
17 changes: 4 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,17 @@ COPY . .

ARG HEROKU_DB
ENV HEROKU_DB=$HEROKU_DB

# config env vars
ENV BOT_TOKEN=YOUR_TOKEN_GOES_HERE
ENV BOT_TOKEN=
ENV SPOTIFY_ID=
ENV SPOTIFY_SECRET=
ENV DATABASE_URL=
ENV BOT_PREFIX=d!
ENV ENABLE_SLASH_COMMANDS=False
ENV MENTION_AS_PREFIX=True
ENV VC_TIMEOUT=600
ENV VC_TIMEOUT_DEFAULT=True
ENV ALLOW_VC_TIMEOUT_EDIT=True
ENV MAX_SONG_PRELOAD=5
ENV ENABLE_SLASH_COMMANDS=False
ENV VC_TIMOUT_DEFAULT=True
ENV MAX_HISTORY_LENGTH=10
ENV MAX_TRACKNAME_HISTORY_LENGTH=15
ENV DATABASE_URL=sqlite:///settings.db
ENV ENABLE_BUTTON_PLUGIN=True
ENV EMBED_COLOR=0x4DD4D0
ENV SUPPORTED_EXTENSIONS="('.webm', '.mp4', '.mp3', '.avi', '.wav', '.m4v', '.ogg', '.mov')"
ENV COOKIE_PATH=config/cookies/cookies.txt
ENV GLOBAL_DISABLE_AUTOJOIN_VC=False

RUN pip --no-cache-dir install -r requirements.txt \
&& apt-get update \
Expand Down
218 changes: 218 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,219 @@
![](https://repository-images.githubusercontent.com/494393877/c7c7a9a7-321a-48a0-b19d-b1e7dcf2a1c0)


# DandelionMusic
A Discord music bot written in Python with support for Youtube, SoundCloud, Spotify, Bandcamp, Twitter, and custom files.

### Keep in mind:
* The Wiki may have the answer you are looking for https://github.com/Krutyi-4el/DandelionMusic/wiki
* Known problems are listed in Issues. If you are interested in this project feel free to submit an Issue.


<h3>What's Coming?</h1>

- See TODO in Projects tab

## Prerequisites:

#### API Keys
* Discord - https://discord.com/developers
* Spotify (optional) - https://developer.spotify.com/dashboard/
- Client ID
- Client Secret
- Note: Limited to 50 playlist items without API

Obtained keys must be entered into ```config.json``` (or set as environment variables)

#### Requirements (skip this if you've decided to use pre-built exe)

* Installation of Python 3.8+

Install dependencies:
```
pip install -r requirements.txt
```

##### Windows
Download `ffmpeg` and put it into a folder in PATH.

If ffmpeg is not found, the script will try to download it automatically.
##### Other platforms
Install `ffmpeg` and `libopus` packages.

### Installing - Self hosting

1. Download release if available, alternatively download repository zip
2. Complete Prerequisites
3. Start ```run.py``` in project root (or the exe)
4. See configuration options in config.json (more info at https://github.com/Krutyi-4el/DandelionMusic/wiki/Configuration)

Button play plugin:
* Set emoji with the setting command to enable this feature
* Emote must be available for bot
* Needs Manage Message permissions

Custom Cookies:
* Extract cookies.txt from you browser using your preferred method
* Overwrite the existing cookies.txt in /config/cookies/
* (Optional) Set a custom cookies.txt location by modifying COOKIE_PATH in config.py

### Docker image

You can find pre-built Docker image at https://hub.docker.com/repository/docker/krutyi4el/dandelion-music/

See https://github.com/Krutyi-4el/DandelionMusic/wiki/Configuration for description of environment variables.

## Commands:

### Music

After the bot has joined your server, use ```d!help``` to display help and command information.


```
d!p [link/video title/key words/playlist-link/soundcloud link/spotify link/bandcamp link/twitter link]
```

* Plays the audio of supported website
- A link to the video (https://ww...)
- The title of a video ex. (Gennifer Flowers - Fever Dolls)
- A link to a YouTube playlist
* If a song is playing, it will be added to queue

#### Playlist Commands

```
d!skip / d!s
```

* Skips the current song and plays next in queue.

```
d!q
```

* Show the list of songs in queue

```
d!shuffle / d!sh
```

* Shuffle the queue

```
d!l / d!loop [all/single/off]
```

* Loops the entire queue by default. `d!loop single` loops current track.

```
d!mv / d!move
```

* Move song position in queue

#### Audio Commands

```
d!pause
```

* Pauses the current song.

```
d!resume
```

* Resumes the paused song.

```
d!prev
```

* Goes back one song and plays the last song again.

```
d!np
```

* Shows more details about the current song.

```
d!volume / d!vol
```

* Adjust the volume 1-100%
* Pass no arguments for current volume

```
d!remove / d!rm
```

* Removes a song from the queue (defaults to last song)

```
d!stop / d!st
```
* Stops the current song and clears the playqueue.


### General

```
d!settings / d!setting / d!set
```
* No Arguments: Lists server settings
* Arguments: (setting) (value)
* Use "unset" as an argument to reset a setting
* Example: d!setting start_voice_channel ChannelName
* Administrators only

```
d!c
```

* Connects the bot to the user's voice channel

```
d!dc
```

* Disconnects the bot from the current voice channel

```
d!history
```
* Shows you the titles of the X last played songs. Configurable in config.config.py


### Utility

```
d!reset / d!rs
```

* Disconnect and reconnect to the voice channel

```
d!ping
```

* Test bot connectivity

```
d!addbot
```

* Displays information on how to add the bot to another server of yours.

## License

This program is free software: you can redistribute it and/or modify
it under the terms of the [GNU General Public License](LICENSE) as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.


## Acknowledgements

https://github.com/adriansteffan/DiscordJockey
16 changes: 3 additions & 13 deletions config/build.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import os
import sys
import glob
import json
import runpy

from config import config

with open("config/config_comments.json", "w") as f:
json.dump(config.get_comments(), f)
from config.config import DATABASE_LIBRARY

sys.argv.extend(
[
Expand All @@ -16,16 +12,10 @@
"--collect-binaries=discord",
# make sure every file from musicbot folder is included
*[
"--hidden-import="
+ os.path.splitext(file)[0].replace(os.path.sep, ".")
"--hidden-import=" + os.path.splitext(file)[0].replace(os.path.sep, ".")
for file in glob.glob("musicbot/**/*.py", recursive=True)
],
"--hidden-import=" + config.DATABASE_LIBRARY,
*[
"--add-data=" + file + os.pathsep + "/"
for file in glob.glob("config/*.json")
],
"-p=config",
"--hidden-import=" + DATABASE_LIBRARY,
"-n=DandelionMusic",
"-i=ui/note.ico",
"run.py",
Expand Down
2 changes: 1 addition & 1 deletion config/cookies/cookies.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Netscape HTTP Cookie File
# https://curl.haxx.se/rfc/cookie_spec.html
# More info at https://github.com/Krutyi-4el/DandelionMusic/wiki/Configuration#custom-cookies
# This is a generated file! Do not edit.
35 changes: 16 additions & 19 deletions config/setup.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
"This file is here to install the selected DB package and jsonc"
"This file is here to automatically install the selected DB package"
import os
import sys
from pathlib import Path

try:
import tomllib
except ImportError:
import tomli as tomllib

from setuptools import setup

from config import Config
# imitate running in root directory
cfg_dir = Path(__file__).parent
for i, path in enumerate(sys.path):
if Path(path).absolute() == cfg_dir:
sys.path[i] = str(cfg_dir.parent)

# inform that we're in installation phase
os.environ["DANDELION_INSTALLING"] = "1"

def main():
with open("db.txt", "w") as f, open("pyproject.toml", "rb") as t:
print(Config().DATABASE_LIBRARY, file=f)
# reuse jsonc already specified in toml
print(tomllib.load(t)["build-system"]["requires"][-1], file=f)

setup()

os.remove("db.txt")
from setuptools import setup
from config.config import DATABASE_LIBRARY


main()
setup(
name="MusicBot DB",
install_requires=[DATABASE_LIBRARY],
)
Binary file added ffmpeg.exe
Binary file not shown.
Loading

0 comments on commit 92c02c3

Please sign in to comment.