[V3 Audio] Only allow audio commands in servers (#1682)

* [V3 Audio] Only allow audio commands in servers

Fixes #1681

* [V3 Audio] Formatting fix
This commit is contained in:
aikaterna 2018-05-22 16:39:01 -07:00 committed by Will
parent 77cdbf8dd6
commit abfee70eb3

View File

@ -302,6 +302,7 @@ class Audio:
await self._embed_msg(ctx, "Song titles as status: {}.".format(not status)) await self._embed_msg(ctx, "Song titles as status: {}.".format(not status))
@commands.command() @commands.command()
@commands.guild_only()
async def audiostats(self, ctx): async def audiostats(self, ctx):
"""Audio stats.""" """Audio stats."""
server_num = len([p for p in lavalink.players if p.current is not None]) server_num = len([p for p in lavalink.players if p.current is not None])
@ -336,6 +337,7 @@ class Audio:
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command() @commands.command()
@commands.guild_only()
async def bump(self, ctx, index: int): async def bump(self, ctx, index: int):
"""Bump a song number to the top of the queue.""" """Bump a song number to the top of the queue."""
dj_enabled = await self.config.guild(ctx.guild).dj_enabled() dj_enabled = await self.config.guild(ctx.guild).dj_enabled()
@ -361,6 +363,7 @@ class Audio:
await self._embed_msg(ctx, "Moved {} to the top of the queue.".format(removed.title)) await self._embed_msg(ctx, "Moved {} to the top of the queue.".format(removed.title))
@commands.command(aliases=["dc"]) @commands.command(aliases=["dc"])
@commands.guild_only()
async def disconnect(self, ctx): async def disconnect(self, ctx):
"""Disconnect from the voice channel.""" """Disconnect from the voice channel."""
dj_enabled = await self.config.guild(ctx.guild).dj_enabled() dj_enabled = await self.config.guild(ctx.guild).dj_enabled()
@ -377,6 +380,7 @@ class Audio:
return await lavalink.get_player(ctx.guild.id).disconnect() return await lavalink.get_player(ctx.guild.id).disconnect()
@commands.command(aliases=["np", "n", "song"]) @commands.command(aliases=["np", "n", "song"])
@commands.guild_only()
async def now(self, ctx): async def now(self, ctx):
"""Now playing.""" """Now playing."""
if not self._player_check(ctx): if not self._player_check(ctx):
@ -444,6 +448,7 @@ class Audio:
await ctx.invoke(self.skip) await ctx.invoke(self.skip)
@commands.command(aliases=["resume"]) @commands.command(aliases=["resume"])
@commands.guild_only()
async def pause(self, ctx): async def pause(self, ctx):
"""Pause and resume.""" """Pause and resume."""
dj_enabled = await self.config.guild(ctx.guild).dj_enabled() dj_enabled = await self.config.guild(ctx.guild).dj_enabled()
@ -488,6 +493,7 @@ class Audio:
await self._embed_msg(ctx, "Nothing playing.") await self._embed_msg(ctx, "Nothing playing.")
@commands.command() @commands.command()
@commands.guild_only()
async def percent(self, ctx): async def percent(self, ctx):
"""Queue percentage.""" """Queue percentage."""
if not self._player_check(ctx): if not self._player_check(ctx):
@ -543,6 +549,7 @@ class Audio:
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command() @commands.command()
@commands.guild_only()
async def play(self, ctx, *, query): async def play(self, ctx, *, query):
"""Play a URL or search for a song.""" """Play a URL or search for a song."""
dj_enabled = await self.config.guild(ctx.guild).dj_enabled() dj_enabled = await self.config.guild(ctx.guild).dj_enabled()
@ -997,6 +1004,7 @@ class Audio:
return tracklist return tracklist
@commands.command() @commands.command()
@commands.guild_only()
async def prev(self, ctx): async def prev(self, ctx):
"""Skips to the start of the previously played track.""" """Skips to the start of the previously played track."""
if not self._player_check(ctx): if not self._player_check(ctx):
@ -1035,6 +1043,7 @@ class Audio:
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(aliases=["q"]) @commands.command(aliases=["q"])
@commands.guild_only()
async def queue(self, ctx, page: int = 1): async def queue(self, ctx, page: int = 1):
"""Lists the queue.""" """Lists the queue."""
if not self._player_check(ctx): if not self._player_check(ctx):
@ -1110,6 +1119,7 @@ class Audio:
return embed return embed
@commands.command() @commands.command()
@commands.guild_only()
async def repeat(self, ctx): async def repeat(self, ctx):
"""Toggles repeat.""" """Toggles repeat."""
dj_enabled = await self.config.guild(ctx.guild).dj_enabled() dj_enabled = await self.config.guild(ctx.guild).dj_enabled()
@ -1133,6 +1143,7 @@ class Audio:
await self._embed_msg(ctx, "Repeat songs: {}.".format(repeat)) await self._embed_msg(ctx, "Repeat songs: {}.".format(repeat))
@commands.command() @commands.command()
@commands.guild_only()
async def remove(self, ctx, index: int): async def remove(self, ctx, index: int):
"""Remove a specific song number from the queue.""" """Remove a specific song number from the queue."""
dj_enabled = await self.config.guild(ctx.guild).dj_enabled() dj_enabled = await self.config.guild(ctx.guild).dj_enabled()
@ -1159,6 +1170,7 @@ class Audio:
await self._embed_msg(ctx, "Removed {} from the queue.".format(removed.title)) await self._embed_msg(ctx, "Removed {} from the queue.".format(removed.title))
@commands.command() @commands.command()
@commands.guild_only()
async def search(self, ctx, *, query): async def search(self, ctx, *, query):
"""Pick a song with a search. """Pick a song with a search.
Use [p]search list <search term> to queue all songs found on YouTube. Use [p]search list <search term> to queue all songs found on YouTube.
@ -1314,6 +1326,7 @@ class Audio:
return embed return embed
@commands.command() @commands.command()
@commands.guild_only()
async def seek(self, ctx, seconds: int = 30): async def seek(self, ctx, seconds: int = 30):
"""Seeks ahead or behind on a track by seconds.""" """Seeks ahead or behind on a track by seconds."""
dj_enabled = await self.config.guild(ctx.guild).dj_enabled() dj_enabled = await self.config.guild(ctx.guild).dj_enabled()
@ -1346,6 +1359,7 @@ class Audio:
await self._embed_msg(ctx, "Nothing playing.") await self._embed_msg(ctx, "Nothing playing.")
@commands.command() @commands.command()
@commands.guild_only()
async def shuffle(self, ctx): async def shuffle(self, ctx):
"""Toggles shuffle.""" """Toggles shuffle."""
dj_enabled = await self.config.guild(ctx.guild).dj_enabled() dj_enabled = await self.config.guild(ctx.guild).dj_enabled()
@ -1367,6 +1381,7 @@ class Audio:
await self._embed_msg(ctx, "Shuffle songs: {}.".format(shuffle)) await self._embed_msg(ctx, "Shuffle songs: {}.".format(shuffle))
@commands.command(aliases=["forceskip", "fs"]) @commands.command(aliases=["forceskip", "fs"])
@commands.guild_only()
async def skip(self, ctx): async def skip(self, ctx):
"""Skips to the next track.""" """Skips to the next track."""
if not self._player_check(ctx): if not self._player_check(ctx):
@ -1497,6 +1512,7 @@ class Audio:
await player.skip() await player.skip()
@commands.command(aliases=["s"]) @commands.command(aliases=["s"])
@commands.guild_only()
async def stop(self, ctx): async def stop(self, ctx):
"""Stops playback and clears the queue.""" """Stops playback and clears the queue."""
dj_enabled = await self.config.guild(ctx.guild).dj_enabled() dj_enabled = await self.config.guild(ctx.guild).dj_enabled()
@ -1529,6 +1545,7 @@ class Audio:
player.store("requester", None) player.store("requester", None)
@commands.command() @commands.command()
@commands.guild_only()
async def volume(self, ctx, vol: int = None): async def volume(self, ctx, vol: int = None):
"""Sets the volume, 1% - 150%.""" """Sets the volume, 1% - 150%."""
dj_enabled = await self.config.guild(ctx.guild).dj_enabled() dj_enabled = await self.config.guild(ctx.guild).dj_enabled()
@ -1572,6 +1589,7 @@ class Audio:
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.group(aliases=["llset"]) @commands.group(aliases=["llset"])
@commands.guild_only()
@checks.is_owner() @checks.is_owner()
async def llsetup(self, ctx): async def llsetup(self, ctx):
"""Lavalink server configuration options.""" """Lavalink server configuration options."""