Rename stream to play
This commit is contained in:
parent
514c6c15c2
commit
07f8f3e524
|
@ -15,7 +15,7 @@ class Music(commands.Cog):
|
|||
self.bot = bot
|
||||
|
||||
@commands.command()
|
||||
async def stream(self, ctx, *, url):
|
||||
async def play(self, ctx, *, url):
|
||||
async with ctx.typing():
|
||||
player = await YTDLSource.from_url(url, loop=self.bot.loop, stream=True)
|
||||
ctx.voice_client.play(player, after=lambda e: print(f"Player error: {e}") if e else None)
|
||||
|
@ -26,7 +26,7 @@ class Music(commands.Cog):
|
|||
async def stop(self, ctx):
|
||||
await ctx.voice_client.disconnect()
|
||||
|
||||
@stream.before_invoke
|
||||
@play.before_invoke
|
||||
async def ensure_voice(self, ctx):
|
||||
if ctx.voice_client is None:
|
||||
if ctx.author.voice:
|
||||
|
|
|
@ -39,7 +39,7 @@ async def test_bot_ensure_voice(bot, ctx):
|
|||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_bot_stream(bot, ctx):
|
||||
async def test_bot_play(bot, ctx):
|
||||
mbot = Music(bot)
|
||||
|
||||
with patch('bot.YTDLSource', new_callable=AsyncMock) as ytdl_source:
|
||||
|
@ -47,7 +47,7 @@ async def test_bot_stream(bot, ctx):
|
|||
ytdl_source.from_url.return_value = player
|
||||
url = 'A Day To Remember - All I Want'
|
||||
# pylint: disable=too-many-function-args
|
||||
await mbot.stream(mbot, ctx, url=url)
|
||||
await mbot.play(mbot, ctx, url=url)
|
||||
assert ytdl_source.from_url.await_args.args == (url,)
|
||||
assert ytdl_source.from_url.await_args.kwargs == {"loop": bot.loop, "stream": True}
|
||||
assert ctx.voice_client.play.call_args.args == (player,)
|
||||
|
|
Loading…
Reference in New Issue