diff --git a/.github/workflows/build.yml-wait b/.github/workflows/build.yml similarity index 66% rename from .github/workflows/build.yml-wait rename to .github/workflows/build.yml index a49fd18..d92a696 100644 --- a/.github/workflows/build.yml-wait +++ b/.github/workflows/build.yml @@ -4,8 +4,10 @@ on: [push, pull_request] jobs: flake8: runs-on: ubuntu-latest + env: + CheckFiles: "bot.py cogs/" steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: Set up Python 3.8 uses: actions/setup-python@v1 with: @@ -13,7 +15,25 @@ jobs: - name: Lint with flake8 run: | pip install flake8 - flake8 --max-line-length 120 --statistics ${FLAKE_FILES} + flake8 ${CheckFiles} + + - name: Check with Isort + run: | + pip install isort + isort --check --sp setup.cfg ${CheckFiles} + - name: Sort with Isort + if: failure() + run: | + isort --sp setup.cfg ${CheckFiles} + - name: Create Pull Request + if: failure() + uses: peter-evans/create-pull-request@v2 + with: + token: ${{ secrets.GH_TOKEN }} + branch: actions/auto + commit-message: Changes done by tests + committer: Roxedus + title: Linter changed files build-and-push: needs: flake8 @@ -23,8 +43,9 @@ jobs: ref: ${{github.ref}} DOCKER_USERNAME: roxedus DOCKER_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} + steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: Build the Docker image run: | branch="${ref##*/}" diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..aacd762 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + "recommendations": [ + "oderwat.indent-rainbow", + "ms-python.python", + "ms-python.vscode-pylance" + ] +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..958f4d6 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [{ + "name": "Debug Bot", + "type": "python", + "request": "launch", + "program": "bot.py", + "console": "integratedTerminal", + "args": ["-D", "-d", "data"], + "host": "localhost" + }] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..3f76c37 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,15 @@ +{ + "python.languageSever": "Pylance", + "python.linting.enabled": true, + "python.linting.pylintEnabled": true, + "python.linting.flake8Enabled": true, + "python.linting.pycodestyleEnabled": true, + "[python]": { + "editor.rulers": [120], + }, + "[Dockerfile]": { + "editor.formatOnSave": false + }, + "editor.tabSize": 4 + +} \ No newline at end of file diff --git a/README.md b/README.md index a7a965f..09f97ec 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,10 @@ # WIP - Shite Music Bot [![Build Status](https://jenkins.roxedus.net/buildStatus/icon?job=MusicBot%2Fdev)](https://jenkins.roxedus.net/job/MusicBot/job/dev/) -[![](https://images.microbadger.com/badges/image/rnorge/music:dev-amd64.svg)](https://microbadger.com/images/rnorge/music:dev-amd64 "Get your own image badge on microbadger.com") +[![MicroBadger](https://images.microbadger.com/badges/image/rnorge/music:dev-amd64.svg)](https://microbadger.com/images/rnorge/music:dev-amd64 "Get your own image badge on microbadger.com") + +## Features -### Features: - Translations, get the bot in your preferred langauge! - Round Robin style queue, you won't have to wait forever for your songs to play. - Noice per server customization options. @@ -12,18 +13,19 @@ - Lyrics command that sometimes gives the correct lyrics - DJ roles +### Setup -#### Setup 1. Change or copy data/config.yaml.example to config.yaml 2. Create or find a [lavalink](https://github.com/Frederikam/Lavalink) server you can use. 3. Add your bot token and lavalink server. 4. Edit any other settings you want. -5. install requirements -> python -m pip install -r requirements.txt +5. install requirements `python -m pip install -r requirements.txt` 6. run the bot :) -#### Docker -#### Compose Example: +### Docker + +### Compose Example + ````yaml version: '3' networks: @@ -42,7 +44,7 @@ services: - lavalink volumes: - /compose/BottStack/lavalink/application.yml:/opt/Lavalink/application.yml - bot: + bot: container_name: ProdMaster image: rnorge/music networks: @@ -51,4 +53,4 @@ services: volumes: - /compose/BottStack/ProdBetaMaster/script:/diks - /compose/BottStack/ProdBetaMaster/data:/app/data -```` \ No newline at end of file +```` diff --git a/cogs/errors.py b/cogs/errors.py index f0ea6da..92117d7 100644 --- a/cogs/errors.py +++ b/cogs/errors.py @@ -57,10 +57,9 @@ class Errors(commands.Cog): elif (err.original == 'You need to be in my voicechannel.'): return await send_error_embed('{errors.my_channel}') - if isinstance(err, commands.CommandOnCooldown): await ctx.send(f"{ctx.message.author.mention} Command is on cooldown. " - f"Try again in `{err.retry_after:.1f}` seconds.") + f"Try again in `{err.retry_after:.1f}` seconds.") elif isinstance(err, commands.NoPrivateMessage): await ctx.send('That command is not available in DMs') @@ -70,11 +69,11 @@ class Errors(commands.Cog): if self.bot.debug: tb = err.__traceback__ traceback.print_tb(tb) - self.logger.debug("Error running command: %s\nTraceback: %s" % (ctx.command, err)) + self.logger.debug("Error running command: %s\nTraceback: %s" % (ctx.command, err)) else: to_log = (RuntimeError, commands.CheckFailure, commands.CommandInvokeError, - commands.NoPrivateMessage) + commands.NoPrivateMessage) if isinstance(err, to_log): self.logger.debug("Error running command: %s\nTraceback: %s" % (ctx.command, err)) diff --git a/cogs/music.py b/cogs/music.py index 3742dce..9720aad 100644 --- a/cogs/music.py +++ b/cogs/music.py @@ -16,7 +16,6 @@ from typing import Optional from bs4 import BeautifulSoup from .utils import checks, thumbnailer, timeformatter -from .utils.mixplayer import MixPlayer from .utils.paginator import QueuePaginator, Scroller, TextPaginator from .utils.selector import Selector diff --git a/cogs/nodemanager.py b/cogs/nodemanager.py index 81f8530..ef08c9b 100644 --- a/cogs/nodemanager.py +++ b/cogs/nodemanager.py @@ -8,9 +8,11 @@ import codecs import yaml -from .utils.mixplayer import MixPlayer +# Bot Utilities from cogs.helpformatter import commandhelper from cogs.utils.paginator import Scroller +from .utils.mixplayer import MixPlayer + class NodeManager(commands.Cog): def __init__(self, bot): @@ -51,7 +53,7 @@ class NodeManager(commands.Cog): if node['name'] in name_cache: continue - self.bot.lavalink.add_node(**node) + self.bot.lavalink.add_node(**node) self.logger.debug("Adding Lavalink node: %s on %s with the port %s in %s" % ( node['name'], node['host'], node['port'], node['region'],)) diff --git a/cogs/utils/alias.py b/cogs/utils/alias.py index d7a0f2a..8a68d61 100644 --- a/cogs/utils/alias.py +++ b/cogs/utils/alias.py @@ -6,7 +6,6 @@ from os import path import yaml - """ Not the prettiest this, works by replacing any found aliases in a command string with the actual command names. Allows per guild aliases of subcommands without doing anything to discord.py itself. Suggestions of better/correct diff --git a/setup.cfg b/setup.cfg index fce66fb..92598fc 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,7 @@ -[pycodestyle] -max_line_length = 120 +[flake8] +max-line-length = 120 +count = True +statistics = True [isort] known_discord = discord,lavalink @@ -11,4 +13,14 @@ no_lines_before = LOCALFOLDER indent = " " line_length = 120 balanced_wrapping = True -multi_line_output = 4 \ No newline at end of file +multi_line_output = 4 + +[pycodestyle] +max_line_length = 120 + +[pylint.FORMAT] +max-line-length=120 + +[pylint.BASIC] +variable-naming-style=camelCase +constant-naming-style=camelCase