mirror of
https://github.com/UiO-Gaming/ShiteMusicBot.git
synced 2026-11-05 13:56:51 +01:00
Update dependencies, force disconnect on empty voice, more typing
This commit is contained in:
1 parent
61d0bfb4d1
commit
ef37fe26d9
4 files changed
+15
-21
No files matched your search
@@ -47,12 +47,12 @@ class MusicBot(commands.Bot):
|
|||||||
self.settings = Settings(datadir, **conf['default server settings'])
|
self.settings = Settings(datadir, **conf['default server settings'])
|
||||||
self.APIkeys = conf.get('APIkeys', {})
|
self.APIkeys = conf.get('APIkeys', {})
|
||||||
|
|
||||||
self.localizer = Localizer(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(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.datadir = datadir
|
||||||
self.debug = debug
|
self.debug: bool = debug
|
||||||
self.main_logger = logger
|
self.main_logger: BotLogger = logger
|
||||||
self.logger = self.main_logger.bot_logger.getChild("Bot")
|
self.logger = self.main_logger.bot_logger.getChild("Bot")
|
||||||
self.logger.debug("Debug: %s" % debug)
|
self.logger.debug("Debug: %s" % debug)
|
||||||
self.lavalink: Optional[lavalink.Client] = None
|
self.lavalink: Optional[lavalink.Client] = None
|
||||||
@@ -66,7 +66,7 @@ class MusicBot(commands.Bot):
|
|||||||
ctx = await self.get_context(message, cls=LocalizedContext)
|
ctx = await self.get_context(message, cls=LocalizedContext)
|
||||||
|
|
||||||
# Replace aliases with commands
|
# Replace aliases with commands
|
||||||
ctx = self.aliaser.get_command(ctx)
|
ctx: LocalizedContext = self.aliaser.get_command(ctx)
|
||||||
|
|
||||||
# Add the localizer
|
# Add the localizer
|
||||||
if ctx.command and ctx.command.cog_name:
|
if ctx.command and ctx.command.cog_name:
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ default:
|
|||||||
# Make a new virtual environment
|
# Make a new virtual environment
|
||||||
[private]
|
[private]
|
||||||
make_venv:
|
make_venv:
|
||||||
python3.10 -m venv {{env_name}}
|
python3 -m venv {{env_name}}
|
||||||
{{python}} -m pip install --upgrade pip
|
{{python}} -m pip install --upgrade pip
|
||||||
{{python}} -m pip install -r requirements.txt
|
{{python}} -m pip install -r requirements.txt
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ from .decorators import require_playing, require_queue, require_voice_connection
|
|||||||
from .music_errors import MusicError, PlayerNotAvailableError, WrongTextChannelError
|
from .music_errors import MusicError, PlayerNotAvailableError, WrongTextChannelError
|
||||||
from .voice_client import BasicVoiceClient
|
from .voice_client import BasicVoiceClient
|
||||||
|
|
||||||
time_rx = re.compile('[0-9]+')
|
|
||||||
url_rx = re.compile('https?:\\/\\/(?:www\\.)?.+')
|
url_rx = re.compile('https?:\\/\\/(?:www\\.)?.+')
|
||||||
|
|
||||||
|
|
||||||
@@ -199,19 +198,13 @@ class Music(commands.Cog):
|
|||||||
@checks.dj_or(alone=True, track_requester=True)
|
@checks.dj_or(alone=True, track_requester=True)
|
||||||
@require_voice_connection()
|
@require_voice_connection()
|
||||||
@require_playing(require_user_listening=True)
|
@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."""
|
"""Seeks to a given position in a track."""
|
||||||
player = self.get_player(ctx.guild)
|
player = self.get_player(ctx.guild)
|
||||||
if seconds := time_rx.search(time):
|
track_time = player.position + seconds * 1000 # milliseconds
|
||||||
# Convert to milliseconds, include sign
|
await player.seek(int(track_time))
|
||||||
milliseconds = int(seconds.group())*1000 * (-1 if time.startswith('-1') else 1)
|
msg = ctx.localizer.format_str("{seek.track_moved}", _position=timeformatter.format_ms(track_time))
|
||||||
|
return await ctx.send(msg)
|
||||||
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}"))
|
|
||||||
|
|
||||||
@commands.command(name='skip')
|
@commands.command(name='skip')
|
||||||
@require_voice_connection()
|
@require_voice_connection()
|
||||||
@@ -868,8 +861,9 @@ class Music(commands.Cog):
|
|||||||
if len(player.listeners) == 0 and player.is_connected:
|
if len(player.listeners) == 0 and player.is_connected:
|
||||||
if player.queue.empty and player.current is None:
|
if player.queue.empty and player.current is None:
|
||||||
await player.stop()
|
await player.stop()
|
||||||
|
voice_client: BasicVoiceClient
|
||||||
if voice_client := guild.voice_client:
|
if voice_client := guild.voice_client:
|
||||||
await voice_client.disconnect(force=False)
|
await voice_client.disconnect(force=True)
|
||||||
|
|
||||||
async def leave_check(self):
|
async def leave_check(self):
|
||||||
for player_id in self.lavalink.player_manager.players:
|
for player_id in self.lavalink.player_manager.players:
|
||||||
|
|||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
discord.py == 2.0.*
|
discord.py == 2.3.*
|
||||||
lavalink == 4.0.*
|
lavalink == 4.0.*
|
||||||
asyncio
|
asyncio
|
||||||
pyyaml
|
pyyaml
|
||||||
BeautifulSoup4
|
BeautifulSoup4
|
||||||
pytest
|
pytest
|
||||||
ruff==0.0.263
|
ruff==0.0.274
|
||||||
pre-commit
|
pre-commit
|
||||||
Reference in new issue
Block a user