Giter VIP home page Giter VIP logo

py-music-bot's Introduction

discord.py MusicBot

A simple, unintrusive musicbot written in Discord.py that utilizes YoutubeDL and ffmpeg to stream audio. Use the help command to get a list of commands!

Getting started

If you just want to get up and running with the bot quickly:

  1. Clone this repository using the GitHub website or GitHub/git CLI.
  2. Install pipenv, the Python dependency manager, if necessary. Also, ensure opus and ffmpeg are installed on your machine and available in your environment. Both are used for media streaming.
  3. Navigate into the project directory and run pipenv install to install dependencies.
  4. Activate the Pipenv using pipenv shell. Run the bot using python -m musicbot.
  5. On first startup, a default config.toml will be generated without an API token, so the bot will abort complaining that No token has been provided. Fill your bot's token into config.toml.
  6. Use something like the Discord API Permissions calculator to generate an invite link and invite your bot to your server, if necessary.
  7. Run the bot using python -m musicbot.

Additional Dependencies

Make sure that pipenv is installed. Navigate to the project directory, and run pipenv install to install the Python dependencies.

To allow for streaming of media, make sure opus and ffmpeg are installed and in your environment.

To run the bot, activate the virtual environment with pipenv shell and then python -m musicbot to start the bot.

Configuring

When you run the bot for the first time, a default configuration file will be generated called config.toml. You can enter that file and add your token, etc. The default file looks like this:

"token"="" # the bot's token
"prefix"="!" # prefix used to denote commands

[music]
# Options for the music commands
"max_volume"=250 # Max audio volume. Set to -1 for unlimited.
"vote_skip"=true # whether vote-skipping is enabled
"vote_skip_ratio"=0.5 # the minimum ratio of votes needed to skip a song
[tips]
"github_url"="https://github.com/joek13/py-music-bot"

If you ever wish to restore the bot to default configuration, you can simply delete (or rename) your config file. A new one will be generated upon startup.

Commands

From the bot's help command:

Meta:
  uptime Tells how long the bot has been running.
Music:
  leave  Leaves the voice channel, if currently in one.
  play   Plays audio from <url>.
Tips:
  tip    Get a random tip about using the bot.
​No Category:
  help   Shows this message

Contributing

Issues and pull requests are welcomed and appreciated. I can't guarantee that I will respond to all issues in a timely manner, but I will try my best to respond to any issues that arise.

py-music-bot's People

Contributors

dependabot[bot] avatar joek13 avatar redkrieg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

py-music-bot's Issues

Main.py line no.5 error

Traceback (most recent call last):
File "main.py", line 5, in
from .cogs import music, error, meta, tips
ImportError: attempted relative import with no known parent package

Add on_message event

I'm trying to do this:

musicbot/cogs/reply.py

import discord

class Reply:
    def __init__(self, discordClient):
        self.client = discordClient

    async def on_message(self, message):
        if message.author == self.user:
            return

        if message.content.startswith('$hello'):
            await message.channel.send('Hello World!')
        await client.process_commands(message)

musicbot/bot.py

import discord
import logging
import sys
from discord.ext import commands
from .cogs import music, error, meta, tips, reply
from . import config

cfg = config.load_config()
bot = commands.Bot(command_prefix=cfg["prefix"])
discordClient = discord.Client

@bot.event
async def on_ready():
    logging.info(f"Bot logado como {bot.user.name}")

COGS = [music.Music, error.CommandErrorHandler, meta.Meta, tips.Tips]

def add_cogs(bot):
    for cog in COGS:
        bot.add_cog(cog(bot, cfg))
    bot.add_cog(reply.Reply(discordClient))

def run():
    add_cogs(bot)
    if cfg["token"] == "":
        raise ValueError("Nenhum token fornecido. Por favor verifique se o arquivo config.toml contem o token do bot.")
        sys.exit(1)
    bot.run(cfg["token"])

And i get this error:

musicbot@persephone:~/bot$ pipenv run python3 -m musicbot
Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/var/musicbot/bot/musicbot/__main__.py", line 18, in <module>
    bot.run()
  File "/var/musicbot/bot/musicbot/bot.py", line 24, in run
    add_cogs(bot)
  File "/var/musicbot/bot/musicbot/bot.py", line 21, in add_cogs
    bot.add_cog(reply.Reply(discordClient))
  File "/var/musicbot/.local/share/virtualenvs/bot-BNrfCbEZ/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 505, in add_cog
    raise TypeError('cogs must derive from Cog')
TypeError: cogs must derive from Cog

If anyone can help.

Age restricted videos unplayable

Getting this error when trying to play (what I suppose are) age restricted videos on youtube.

WARNING: unable to download video info webpage: HTTP Error 410: Gone
ERROR: Sign in to confirm your age
This video may be inappropriate for some users.

Read up on it and seems like it should be fixable by adding your cookies to youtube-dl if I understood it correctly. whatdaybob/sonarr_youtubedl#20. I'm quite new to this and if there's anything I can do to fix this let me know.

Can this still be used?

I have entered the TOKEN and the prefix according to what you said, but it has always reported errors, I hope to have an answer!
註解 2020-05-24 151300

some error when i run main.py

ster/src/main.py
Traceback (most recent call last):
File "c:/Users/Pankaj/Desktop/py-music-bot-master/src/main.py", line 20, in
bot.run()
File "c:\Users\Pankaj\Desktop\py-music-bot-master\src\bot.py", line 27, in run
add_cogs(bot)
File "c:\Users\Pankaj\Desktop\py-music-bot-master\src\bot.py", line 23, in add_cogs
bot.add_cog(cog(bot, cfg)) # Initialize the cog and add it to the bot
File "C:\Users\Pankaj\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\bot.py", line 506, in add_cog
raise TypeError('cogs must derive from Cog')
TypeError: cogs must derive from Cog
PS C:\Users\Pankaj\Desktop\py-music-bot-master>

Songs not completing

Songs don't seem to be completing fully. They make it about halfway and then stop playing or continue to next song.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.