Fix audio command issues
This commit is contained in:
parent
47b584e089
commit
f8644bbe1a
1 changed files with 31 additions and 3 deletions
|
|
@ -55,6 +55,10 @@ class MusicCog(commands.Cog):
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def play(self, ctx, url):
|
async def play(self, ctx, url):
|
||||||
"""Streams from a url"""
|
"""Streams from a url"""
|
||||||
|
|
||||||
|
if ctx.author.voice is None:
|
||||||
|
return await ctx.send("You're not connected to a voice channel.")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
channel = ctx.author.voice.channel
|
channel = ctx.author.voice.channel
|
||||||
await channel.connect()
|
await channel.connect()
|
||||||
|
|
@ -77,7 +81,12 @@ class MusicCog(commands.Cog):
|
||||||
@commands.command(aliases=['disconnect, dc'])
|
@commands.command(aliases=['disconnect, dc'])
|
||||||
async def leave(self, ctx):
|
async def leave(self, ctx):
|
||||||
"""Disconnects bot from the voice channel"""
|
"""Disconnects bot from the voice channel"""
|
||||||
|
|
||||||
|
if ctx.author.voice is None:
|
||||||
|
return await ctx.send("You're not connected to a voice channel.")
|
||||||
|
|
||||||
voice = ctx.voice_client
|
voice = ctx.voice_client
|
||||||
|
if voice is not None:
|
||||||
if voice.is_connected():
|
if voice.is_connected():
|
||||||
await voice.disconnect()
|
await voice.disconnect()
|
||||||
else:
|
else:
|
||||||
|
|
@ -87,6 +96,9 @@ class MusicCog(commands.Cog):
|
||||||
async def volume(self, ctx, volume: int):
|
async def volume(self, ctx, volume: int):
|
||||||
"""Changes the player's volume"""
|
"""Changes the player's volume"""
|
||||||
|
|
||||||
|
if ctx.author.voice is None:
|
||||||
|
return await ctx.send("You're not connected to a voice channel.")
|
||||||
|
|
||||||
if ctx.voice_client is None:
|
if ctx.voice_client is None:
|
||||||
return await ctx.send("Not connected to a voice channel.")
|
return await ctx.send("Not connected to a voice channel.")
|
||||||
|
|
||||||
|
|
@ -96,6 +108,10 @@ class MusicCog(commands.Cog):
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def pause(self, ctx):
|
async def pause(self, ctx):
|
||||||
"""Pauses audio"""
|
"""Pauses audio"""
|
||||||
|
|
||||||
|
if ctx.author.voice is None:
|
||||||
|
return await ctx.send("You're not connected to a voice channel.")
|
||||||
|
|
||||||
voice = ctx.voice_client
|
voice = ctx.voice_client
|
||||||
if voice.is_playing():
|
if voice.is_playing():
|
||||||
voice.pause()
|
voice.pause()
|
||||||
|
|
@ -105,6 +121,10 @@ class MusicCog(commands.Cog):
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def resume(self, ctx):
|
async def resume(self, ctx):
|
||||||
"""Resumes currently paused audio"""
|
"""Resumes currently paused audio"""
|
||||||
|
|
||||||
|
if ctx.author.voice is None:
|
||||||
|
return await ctx.send("You're not connected to a voice channel.")
|
||||||
|
|
||||||
voice = ctx.voice_client
|
voice = ctx.voice_client
|
||||||
if voice.is_paused():
|
if voice.is_paused():
|
||||||
voice.resume()
|
voice.resume()
|
||||||
|
|
@ -115,12 +135,20 @@ class MusicCog(commands.Cog):
|
||||||
async def stop(self, ctx):
|
async def stop(self, ctx):
|
||||||
"""Stops and disconnects the bot from voice"""
|
"""Stops and disconnects the bot from voice"""
|
||||||
|
|
||||||
|
if ctx.author.voice is None:
|
||||||
|
return await ctx.send("You're not connected to a voice channel.")
|
||||||
|
|
||||||
voice = ctx.voice_client
|
voice = ctx.voice_client
|
||||||
|
if voice:
|
||||||
voice.stop()
|
voice.stop()
|
||||||
|
|
||||||
@commands.command(aliases=['join'])
|
@commands.command(aliases=['join'])
|
||||||
async def connect(self, ctx):
|
async def connect(self, ctx):
|
||||||
"""Connects bot to currently connected voice channel"""
|
"""Connects bot to currently connected voice channel"""
|
||||||
|
|
||||||
|
if ctx.author.voice is None:
|
||||||
|
return await ctx.send("You're not connected to a voice channel.")
|
||||||
|
|
||||||
channel = ctx.author.voice.channel
|
channel = ctx.author.voice.channel
|
||||||
try:
|
try:
|
||||||
await channel.connect()
|
await channel.connect()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue