From ee9ed63ba8679b2db95f2313f582f19b110c06c4 Mon Sep 17 00:00:00 2001 From: Ev-1 <33662061+Ev-1@users.noreply.github.com> Date: Thu, 10 Sep 2020 17:28:26 +0200 Subject: [PATCH] Stupid flake 8 >:( --- cogs/errors.py | 3 +++ cogs/music.py | 15 +++++++-------- cogs/utils/checks.py | 2 -- cogs/utils/decorators.py | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cogs/errors.py b/cogs/errors.py index a44fcc7..ab9a645 100644 --- a/cogs/errors.py +++ b/cogs/errors.py @@ -63,6 +63,9 @@ class Errors(commands.Cog): elif (err.original == 'Not listening'): return await send_error_embed('{have_to_listen}') + if isinstance(err, commands.CheckFailure): + pass + 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.") diff --git a/cogs/music.py b/cogs/music.py index 32ee0f9..96eaab3 100644 --- a/cogs/music.py +++ b/cogs/music.py @@ -41,6 +41,7 @@ class Music(commands.Cog): async def cog_before_invoke(self, ctx): """ Ensures a valic player exists whenever a command is run """ region = ctx.guild.region if isinstance(ctx.guild.region, str) else ctx.guild.region.value + # Creates a new only if one doesn't exist, ensures a valid player for all checks. self.bot.lavalink.player_manager.create(ctx.guild.id, endpoint=region) async def connect_to(self, guild_id: int, channel_id: str): @@ -101,7 +102,7 @@ class Music(commands.Cog): @commands.command(name='seek') @checks.dj_or(alone=True, track_requester=True) @require_voice_connection() - @require_playing(ensure_user_listening=True) + @require_playing(require_user_listening=True) async def _seek(self, ctx, *, time: str): """ Seeks to a given position in a track. """ player = self.bot.lavalink.player_manager.get(ctx.guild.id) @@ -155,7 +156,7 @@ class Music(commands.Cog): @commands.command(name='skipto') @checks.dj_or(alone=True) - @require_playing(ensure_user_listening=True) + @require_playing(require_user_listening=True) async def _skip_to(self, ctx, pos: int = 1): """ Plays the queue from a specific point. Disregards tracks before the pos. """ player = self.bot.lavalink.player_manager.get(ctx.guild.id) @@ -172,7 +173,7 @@ class Music(commands.Cog): @commands.command(name='stop') @checks.dj_or(alone=True) @require_voice_connection() - @require_playing(ensure_user_listening=True) + @require_playing(require_user_listening=True) async def _stop(self, ctx): """ Stops the player and clears its queue. """ player = self.bot.lavalink.player_manager.get(ctx.guild.id) @@ -239,7 +240,6 @@ class Music(commands.Cog): scroller = Scroller(ctx, pagified_queue) await scroller.start_scrolling() - @commands.command(name='pause') @checks.dj_or(alone=True) @require_voice_connection() @@ -465,8 +465,7 @@ class Music(commands.Cog): return await ctx.send(ctx.localizer.format_str("{volume.out_of_range}")) await player.set_volume(volume) - embed = discord.Embed(color=ctx.me.color) - embed.description = "{volume.set_to}" + embed = discord.Embed(description="{volume.set_to}", color=ctx.me.color) embed = ctx.localizer.format_embed(embed, _volume=player.volume) await ctx.send(embed=embed) @@ -480,7 +479,7 @@ class Music(commands.Cog): await player.set_volume(100) await player.bassboost(False) - embed = discord.Embed(description='{volume.reset}' , color=ctx.me.color) + embed = discord.Embed(description='{volume.reset}', color=ctx.me.color) embed = ctx.localizer.format_embed(embed) await ctx.send(embed=embed) @@ -592,7 +591,7 @@ class Music(commands.Cog): @commands.command(name='scrub') @checks.dj_or(alone=True) @require_voice_connection() - @require_playing(ensure_user_listening=True) + @require_playing(require_user_listening=True) async def _scrub(self, ctx): """ Lists the first 10 search results from a given query. """ player = self.bot.lavalink.player_manager.get(ctx.guild.id) diff --git a/cogs/utils/checks.py b/cogs/utils/checks.py index 96a1a16..cce1aa2 100644 --- a/cogs/utils/checks.py +++ b/cogs/utils/checks.py @@ -62,7 +62,6 @@ def dj_or(alone: bool = False, track_requester: bool = False): async def predicate(ctx): try: player = ctx.bot.lavalink.player_manager.get(ctx.guild.id) - # Make this false if no player is_alone = (ctx.author in player.listeners and len(player.listeners) == 1) and alone requester = (player.current.requester == ctx.author.id) and track_requester @@ -71,6 +70,5 @@ def dj_or(alone: bool = False, track_requester: bool = False): is_alone = False dj = is_dj(ctx) - print(dj, is_alone, requester) return dj or is_alone or requester return commands.check(predicate) diff --git a/cogs/utils/decorators.py b/cogs/utils/decorators.py index b5c613a..522239f 100644 --- a/cogs/utils/decorators.py +++ b/cogs/utils/decorators.py @@ -4,7 +4,7 @@ from discord.ext import commands import inspect -def ensure_voice_connection(should_connect=False): +def require_voice_connection(should_connect=False): """ Checks if the bot is in a valid voice channel for the command should_connect indicates whether the bot should try to join a channel @@ -53,7 +53,7 @@ def ensure_voice_connection(should_connect=False): return ensure_voice_proper -def require_playing(ensure_user_listening=False): +def require_playing(require_user_listening=False): """ Checks if the bot is currently playing a track ensure_user_listening: also checks if the user is listening to the bot @@ -67,7 +67,7 @@ def require_playing(ensure_user_listening=False): if not player.is_playing: raise commands.CommandInvokeError('Not playing') - if ensure_user_listening and (ctx.author not in player.listeners): + if require_user_listening and (ctx.author not in player.listeners): raise commands.CommandInvokeError('Not listening') else: