Skip to content

Commit

Permalink
Merge pull request #57 from cloudwithax/pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
[pre-commit.ci] pre-commit autoupdate
  • Loading branch information
cloudwithax authored Nov 6, 2023
2 parents 7829086 + db1c66d commit 001b801
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 50 deletions.
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 0 additions & 2 deletions docs/hdi/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
90 changes: 49 additions & 41 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!'))
class MyBot(commands.Bot):
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

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!")



@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)
def __init__(self, bot) -> None:
self.bot = bot

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!")

@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.')


await ctx.author.voice.channel.connect(cls=pomice.Player)
await ctx.send(f'Joined the voice channel `{channel}`')
raise commands.CheckFailure(
"You must be in a voice channel to use this command"
"without specifying the channel argument."
)

@commands.command(name='play')
async def play(self, ctx, *, search: str) -> None:
await ctx.author.voice.channel.connect(cls=pomice.Player)
await ctx.send(f"Joined the voice channel `{channel}`")

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])


Expand Down

0 comments on commit 001b801

Please sign in to comment.