Merge pull request #83 from r-Norge/feature/library_updates

Update dependencies, force disconnect on empty voice, more typing
This commit is contained in:
Ev-1 authored and GitHub committed 2023-06-22 20:46:03 +02:00
commit 7884b155d8
4 files changed
+15 -21

No files matched your search

+5 -5
View File
@@ -47,12 +47,12 @@ class MusicBot(commands.Bot):
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 @@ class MusicBot(commands.Bot):
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:
+1 -1
View File
@@ -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
+7 -13
View File
@@ -39,7 +39,6 @@ from .decorators import require_playing, require_queue, require_voice_connection
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 @@ class Music(commands.Cog):
@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 @@ class Music(commands.Cog):
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:
+2 -2
View File
@@ -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