From 341164a0d23c8e4f6c5055f9bbf42ebc45aa884f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 30 Oct 2023 17:50:45 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.4.0 → v4.5.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.4.0...v4.5.0) - [github.com/psf/black: 23.7.0 → 23.10.1](https://github.com/psf/black/compare/23.7.0...23.10.1) - [github.com/asottile/blacken-docs: 1.15.0 → 1.16.0](https://github.com/asottile/blacken-docs/compare/1.15.0...1.16.0) - [github.com/asottile/pyupgrade: v3.10.1 → v3.15.0](https://github.com/asottile/pyupgrade/compare/v3.10.1...v3.15.0) - [github.com/asottile/reorder-python-imports: v3.10.0 → v3.12.0](https://github.com/asottile/reorder-python-imports/compare/v3.10.0...v3.12.0) - [github.com/asottile/add-trailing-comma: v3.0.1 → v3.1.0](https://github.com/asottile/add-trailing-comma/compare/v3.0.1...v3.1.0) - [github.com/hadialqattan/pycln: v2.2.2 → v2.3.0](https://github.com/hadialqattan/pycln/compare/v2.2.2...v2.3.0) --- .pre-commit-config.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 44c88ff..e6d863b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: check-ast - id: check-builtin-literals @@ -11,29 +11,29 @@ repos: - id: requirements-txt-fixer - id: trailing-whitespace - repo: https://github.com/psf/black - rev: 23.7.0 + rev: 23.10.1 hooks: - id: black language_version: python3.11 - repo: https://github.com/asottile/blacken-docs - rev: 1.15.0 + rev: 1.16.0 hooks: - id: blacken-docs - repo: https://github.com/asottile/pyupgrade - rev: v3.10.1 + rev: v3.15.0 hooks: - id: pyupgrade args: [--py37-plus, --keep-runtime-typing] - repo: https://github.com/asottile/reorder-python-imports - rev: v3.10.0 + rev: v3.12.0 hooks: - id: reorder-python-imports - repo: https://github.com/asottile/add-trailing-comma - rev: v3.0.1 + rev: v3.1.0 hooks: - id: add-trailing-comma - repo: https://github.com/hadialqattan/pycln - rev: v2.2.2 + rev: v2.3.0 hooks: - id: pycln From db1c66dd40a647fba5db05381d4698e5160a4813 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 30 Oct 2023 17:50:54 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/hdi/events.md | 2 -- docs/quickstart.md | 84 +++++++++++++++++++++++++--------------------- 2 files changed, 46 insertions(+), 40 deletions(-) diff --git a/docs/hdi/events.md b/docs/hdi/events.md index 040478b..d91b367 100644 --- a/docs/hdi/events.md +++ b/docs/hdi/events.md @@ -13,11 +13,9 @@ The classes listed here are as they appear in Pomice. When you use them within y the way you use them will be different. Here's an example on how you would use the `TrackStartEvent` within an event listener in a cog: ```py - @commands.Cog.listener async def on_pomice_track_start(self, player: Player, track: Track): ... - ``` ## Event definitions diff --git a/docs/quickstart.md b/docs/quickstart.md index a7be045..f7d2ecd 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -10,63 +10,71 @@ import re from discord.ext import commands -URL_REG = re.compile(r'https?://(?:www\.)?.+') +URL_REG = re.compile(r"https?://(?:www\.)?.+") + class MyBot(commands.Bot): + def __init__(self) -> None: + super().__init__( + command_prefix="!", + activity=discord.Activity( + type=discord.ActivityType.listening, name="to music!" + ), + ) - def __init__(self) -> None: - super().__init__(command_prefix='!', activity=discord.Activity(type=discord.ActivityType.listening, name='to music!')) + self.add_cog(Music(self)) - self.add_cog(Music(self)) - - async def on_ready(self) -> None: - print("I'm online!") - await self.cogs["Music"].start_nodes() + async def on_ready(self) -> None: + print("I'm online!") + await self.cogs["Music"].start_nodes() class Music(commands.Cog): + def __init__(self, bot) -> None: + self.bot = bot - def __init__(self, bot) -> None: - self.bot = bot + self.pomice = pomice.NodePool() - self.pomice = pomice.NodePool() + async def start_nodes(self): + await self.pomice.create_node( + bot=self.bot, + host="127.0.0.1", + port="3030", + password="youshallnotpass", + identifier="MAIN", + ) + print(f"Node is ready!") - async def start_nodes(self): - await self.pomice.create_node(bot=self.bot, host='127.0.0.1', port='3030', - password='youshallnotpass', identifier='MAIN') - print(f"Node is ready!") - - - - @commands.command(name='join', aliases=['connect']) - async def join(self, ctx: commands.Context, *, channel: discord.TextChannel = None) -> None: - - if not channel: - channel = getattr(ctx.author.voice, 'channel', None) + @commands.command(name="join", aliases=["connect"]) + async def join( + self, ctx: commands.Context, *, channel: discord.TextChannel = None + ) -> None: + if not channel: + channel = getattr(ctx.author.voice, "channel", None) if not channel: - raise commands.CheckFailure('You must be in a voice channel to use this command' - 'without specifying the channel argument.') + raise commands.CheckFailure( + "You must be in a voice channel to use this command" + "without specifying the channel argument." + ) + await ctx.author.voice.channel.connect(cls=pomice.Player) + await ctx.send(f"Joined the voice channel `{channel}`") - await ctx.author.voice.channel.connect(cls=pomice.Player) - await ctx.send(f'Joined the voice channel `{channel}`') - - @commands.command(name='play') - async def play(self, ctx, *, search: str) -> None: - - if not ctx.voice_client: + @commands.command(name="play") + async def play(self, ctx, *, search: str) -> None: + if not ctx.voice_client: await ctx.invoke(self.join) - player = ctx.voice_client + player = ctx.voice_client - results = await player.get_tracks(query=f'{search}') + results = await player.get_tracks(query=f"{search}") - if not results: - raise commands.CommandError('No results were found for that search term.') + if not results: + raise commands.CommandError("No results were found for that search term.") - if isinstance(results, pomice.Playlist): + if isinstance(results, pomice.Playlist): await player.play(track=results.tracks[0]) - else: + else: await player.play(track=results[0])