Merge pull request #57 from cloudwithax/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
This commit is contained in:
commit
001b801a15
|
|
@ -2,7 +2,7 @@
|
||||||
# See https://pre-commit.com/hooks.html for more hooks
|
# See https://pre-commit.com/hooks.html for more hooks
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v4.4.0
|
rev: v4.5.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: check-ast
|
- id: check-ast
|
||||||
- id: check-builtin-literals
|
- id: check-builtin-literals
|
||||||
|
|
@ -11,29 +11,29 @@ repos:
|
||||||
- id: requirements-txt-fixer
|
- id: requirements-txt-fixer
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/psf/black
|
||||||
rev: 23.7.0
|
rev: 23.10.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
language_version: python3.11
|
language_version: python3.11
|
||||||
- repo: https://github.com/asottile/blacken-docs
|
- repo: https://github.com/asottile/blacken-docs
|
||||||
rev: 1.15.0
|
rev: 1.16.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: blacken-docs
|
- id: blacken-docs
|
||||||
- repo: https://github.com/asottile/pyupgrade
|
- repo: https://github.com/asottile/pyupgrade
|
||||||
rev: v3.10.1
|
rev: v3.15.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: pyupgrade
|
- id: pyupgrade
|
||||||
args: [--py37-plus, --keep-runtime-typing]
|
args: [--py37-plus, --keep-runtime-typing]
|
||||||
- repo: https://github.com/asottile/reorder-python-imports
|
- repo: https://github.com/asottile/reorder-python-imports
|
||||||
rev: v3.10.0
|
rev: v3.12.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: reorder-python-imports
|
- id: reorder-python-imports
|
||||||
- repo: https://github.com/asottile/add-trailing-comma
|
- repo: https://github.com/asottile/add-trailing-comma
|
||||||
rev: v3.0.1
|
rev: v3.1.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: add-trailing-comma
|
- id: add-trailing-comma
|
||||||
- repo: https://github.com/hadialqattan/pycln
|
- repo: https://github.com/hadialqattan/pycln
|
||||||
rev: v2.2.2
|
rev: v2.3.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: pycln
|
- id: pycln
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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:
|
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
|
```py
|
||||||
|
|
||||||
@commands.Cog.listener
|
@commands.Cog.listener
|
||||||
async def on_pomice_track_start(self, player: Player, track: Track):
|
async def on_pomice_track_start(self, player: Player, track: Track):
|
||||||
...
|
...
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Event definitions
|
## Event definitions
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,17 @@ import re
|
||||||
|
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
URL_REG = re.compile(r'https?://(?:www\.)?.+')
|
URL_REG = re.compile(r"https?://(?:www\.)?.+")
|
||||||
|
|
||||||
|
|
||||||
class MyBot(commands.Bot):
|
class MyBot(commands.Bot):
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
super().__init__(command_prefix='!', activity=discord.Activity(type=discord.ActivityType.listening, name='to music!'))
|
super().__init__(
|
||||||
|
command_prefix="!",
|
||||||
|
activity=discord.Activity(
|
||||||
|
type=discord.ActivityType.listening, name="to music!"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
self.add_cog(Music(self))
|
self.add_cog(Music(self))
|
||||||
|
|
||||||
|
|
@ -25,44 +30,47 @@ class MyBot(commands.Bot):
|
||||||
|
|
||||||
|
|
||||||
class Music(commands.Cog):
|
class Music(commands.Cog):
|
||||||
|
|
||||||
def __init__(self, bot) -> None:
|
def __init__(self, bot) -> None:
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
self.pomice = pomice.NodePool()
|
self.pomice = pomice.NodePool()
|
||||||
|
|
||||||
async def start_nodes(self):
|
async def start_nodes(self):
|
||||||
await self.pomice.create_node(bot=self.bot, host='127.0.0.1', port='3030',
|
await self.pomice.create_node(
|
||||||
password='youshallnotpass', identifier='MAIN')
|
bot=self.bot,
|
||||||
|
host="127.0.0.1",
|
||||||
|
port="3030",
|
||||||
|
password="youshallnotpass",
|
||||||
|
identifier="MAIN",
|
||||||
|
)
|
||||||
print(f"Node is ready!")
|
print(f"Node is ready!")
|
||||||
|
|
||||||
|
@commands.command(name="join", aliases=["connect"])
|
||||||
|
async def join(
|
||||||
@commands.command(name='join', aliases=['connect'])
|
self, ctx: commands.Context, *, channel: discord.TextChannel = None
|
||||||
async def join(self, ctx: commands.Context, *, channel: discord.TextChannel = None) -> None:
|
) -> None:
|
||||||
|
|
||||||
if not channel:
|
if not channel:
|
||||||
channel = getattr(ctx.author.voice, 'channel', None)
|
channel = getattr(ctx.author.voice, "channel", None)
|
||||||
if not channel:
|
if not channel:
|
||||||
raise commands.CheckFailure('You must be in a voice channel to use this command'
|
raise commands.CheckFailure(
|
||||||
'without specifying the channel argument.')
|
"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.author.voice.channel.connect(cls=pomice.Player)
|
||||||
await ctx.send(f'Joined the voice channel `{channel}`')
|
await ctx.send(f"Joined the voice channel `{channel}`")
|
||||||
|
|
||||||
@commands.command(name='play')
|
@commands.command(name="play")
|
||||||
async def play(self, ctx, *, search: str) -> None:
|
async def play(self, ctx, *, search: str) -> None:
|
||||||
|
|
||||||
if not ctx.voice_client:
|
if not ctx.voice_client:
|
||||||
await ctx.invoke(self.join)
|
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:
|
if not results:
|
||||||
raise commands.CommandError('No results were found for that search term.')
|
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])
|
await player.play(track=results.tracks[0])
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue