mirror of
https://github.com/UiO-Gaming/ShiteMusicBot.git
synced 2026-11-05 13:56:51 +01:00
Stupid flake 8 >:(
This commit is contained in:
1 parent
2cb03065a3
commit
ee9ed63ba8
4 files changed
+13
-13
No files matched your search
@@ -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.")
|
||||
|
||||
+7
-8
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user