diff --git a/src/bot.py b/src/bot.py index 702dd73..9026522 100644 --- a/src/bot.py +++ b/src/bot.py @@ -17,9 +17,9 @@ youtube_dl.utils.bug_reports_message = lambda: '' class Music(commands.Cog): def __init__(self, bot): - self.bot = bot - self.queue = asyncio.Queue() - self.queue_lock = asyncio.Lock() + self._bot = bot + self._queue = asyncio.Queue() + self._queue_lock = asyncio.Lock() self._ytdl_format_options = { 'format': 'bestaudio/best', 'outtmpl': '%(extractor)s-%(id)s-%(title)s.%(ext)s', @@ -36,34 +36,34 @@ class Music(commands.Cog): self._ffmpeg_options = { 'options': '-vn' } - self.ytdl = youtube_dl.YoutubeDL(self._ytdl_format_options) + self._ytdl = youtube_dl.YoutubeDL(self._ytdl_format_options) # pylint: disable=no-member - self.handle_playback.start() + self._handle_playback.start() @tasks.loop() - async def handle_playback(self): + async def _handle_playback(self): while True: - await self.queue_lock.acquire() - ctx, url, title = await self.queue.get() + await self._queue_lock.acquire() + ctx, url, title = await self._queue.get() audio = discord.FFmpegPCMAudio(url, **self._ffmpeg_options) def after(err): if err: print(f"Player error: {err}") - self.queue.task_done() - self.queue_lock.release() + self._queue.task_done() + self._queue_lock.release() ctx.voice_client.play(audio, after=after) await ctx.send(f"Now playing: {title}") @commands.command() async def play(self, ctx, *, url): async with ctx.typing(): - data = self.ytdl.extract_info(url, download=False) + data = self._ytdl.extract_info(url, download=False) if 'entries' in data: data = data['entries'][0] title = data.get('title') url = data.get('url') - await self.queue.put((ctx, url, title)) + await self._queue.put((ctx, url, title)) if ctx.voice_client.is_playing(): await ctx.send(f"Queued: {title}")