diff --git a/bot.py b/bot.py index 4083f15..7a6c1c0 100644 --- a/bot.py +++ b/bot.py @@ -47,12 +47,12 @@ def __init__(self, datadir, debug: bool = False): self.settings = Settings(datadir, **conf['default server settings']) self.APIkeys = conf.get('APIkeys', {}) - self.localizer = Localizer(conf.get('locale path', "./localization"), conf.get('locale', 'en_en')) - self.aliaser = Aliaser(conf.get('locale path', "./localization"), conf.get('locale', 'en_en')) + self.localizer: Localizer = Localizer(conf.get('locale path', "./localization"), conf.get('locale', 'en_en')) + self.aliaser: Aliaser = Aliaser(conf.get('locale path', "./localization"), conf.get('locale', 'en_en')) self.datadir = datadir - self.debug = debug - self.main_logger = logger + self.debug: bool = debug + self.main_logger: BotLogger = logger self.logger = self.main_logger.bot_logger.getChild("Bot") self.logger.debug("Debug: %s" % debug) self.lavalink: Optional[lavalink.Client] = None @@ -66,7 +66,7 @@ async def process_commands(self, message): ctx = await self.get_context(message, cls=LocalizedContext) # Replace aliases with commands - ctx = self.aliaser.get_command(ctx) + ctx: LocalizedContext = self.aliaser.get_command(ctx) # Add the localizer if ctx.command and ctx.command.cog_name: diff --git a/justfile b/justfile index b298467..24c3c64 100644 --- a/justfile +++ b/justfile @@ -7,7 +7,7 @@ default: # Make a new virtual environment [private] make_venv: - python3.10 -m venv {{env_name}} + python3 -m venv {{env_name}} {{python}} -m pip install --upgrade pip {{python}} -m pip install -r requirements.txt diff --git a/musicbot/cogs/music/__init__.py b/musicbot/cogs/music/__init__.py index c9f85bb..ece32e3 100644 --- a/musicbot/cogs/music/__init__.py +++ b/musicbot/cogs/music/__init__.py @@ -39,7 +39,6 @@ from .music_errors import MusicError, PlayerNotAvailableError, WrongTextChannelError from .voice_client import BasicVoiceClient -time_rx = re.compile('[0-9]+') url_rx = re.compile('https?:\\/\\/(?:www\\.)?.+') @@ -199,19 +198,13 @@ async def _forceplay(self, ctx, *, query: str): @checks.dj_or(alone=True, track_requester=True) @require_voice_connection() @require_playing(require_user_listening=True) - async def _seek(self, ctx, *, time: str): + async def _seek(self, ctx, *, seconds: int): """Seeks to a given position in a track.""" player = self.get_player(ctx.guild) - if seconds := time_rx.search(time): - # Convert to milliseconds, include sign - milliseconds = int(seconds.group())*1000 * (-1 if time.startswith('-1') else 1) - - track_time = player.position + milliseconds - await player.seek(int(track_time)) - msg = ctx.localizer.format_str("{seek.track_moved}", _position=timeformatter.format_ms(track_time)) - await ctx.send(msg) - else: - await ctx.send(ctx.localizer.format_str("{seek.missing_amount}")) + track_time = player.position + seconds * 1000 # milliseconds + await player.seek(int(track_time)) + msg = ctx.localizer.format_str("{seek.track_moved}", _position=timeformatter.format_ms(track_time)) + return await ctx.send(msg) @commands.command(name='skip') @require_voice_connection() @@ -868,8 +861,9 @@ async def check_leave_voice(self, guild: discord.Guild): if len(player.listeners) == 0 and player.is_connected: if player.queue.empty and player.current is None: await player.stop() + voice_client: BasicVoiceClient if voice_client := guild.voice_client: - await voice_client.disconnect(force=False) + await voice_client.disconnect(force=True) async def leave_check(self): for player_id in self.lavalink.player_manager.players: diff --git a/requirements.txt b/requirements.txt index ec0742f..86bc6dd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ -discord.py == 2.0.* +discord.py == 2.3.* lavalink == 4.0.* asyncio pyyaml BeautifulSoup4 pytest -ruff==0.0.263 +ruff==0.0.274 pre-commit