From 93ca7abc1a3af722567d3447bf6d27a81bc22337 Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 22 Feb 2018 20:44:06 -0500 Subject: [PATCH] [V3 Core Commands] Limit status modifying commands to be run in guild only (#1331) * Limit status modifying commands to be run in guild only * JK let em run. * Add a space --- redbot/core/core_commands.py | 55 +++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/redbot/core/core_commands.py b/redbot/core/core_commands.py index d52b8c710..997613e30 100644 --- a/redbot/core/core_commands.py +++ b/redbot/core/core_commands.py @@ -375,10 +375,14 @@ class Core: @_set.command(name="game") @checks.is_owner() - @commands.guild_only() async def _game(self, ctx, *, game: str=None): - """Sets Red's playing status""" - status = ctx.me.status + """Sets Red's playing status + + Can only be run if the bot is in a server.""" + if len(ctx.bot.guilds) == 0: + await ctx.send_help() + return + status = ctx.bot.guilds[0].me.status if game: game = discord.Game(name=game) else: @@ -389,8 +393,13 @@ class Core: @_set.command(name="listening") @checks.is_owner() async def _listening(self, ctx, *, listening: str=None): - """Sets Red's listening status""" - status = ctx.me.status + """Sets Red's listening status + + Can only be run if the bot is in a server.""" + if len(ctx.bot.guilds) == 0: + await ctx.send_help() + return + status = ctx.bot.guilds[0].me.status if listening: listening = discord.Game(name=listening, type=2) else: @@ -401,8 +410,13 @@ class Core: @_set.command(name="watching") @checks.is_owner() async def _watching(self, ctx, *, watching: str=None): - """Sets Red's watching status""" - status = ctx.me.status + """Sets Red's watching status + + Can only be run if the bot is in a server.""" + if len(ctx.bot.guilds) == 0: + await ctx.send_help() + return + status = ctx.bot.guilds[0].me.status if watching: watching = discord.Game(name=watching, type=3) else: @@ -412,23 +426,28 @@ class Core: @_set.command() @checks.is_owner() - @commands.guild_only() async def status(self, ctx, *, status: str): """Sets Red's status + Available statuses: online idle dnd - invisible""" + invisible + + Can only be run if the bot is in a server.""" statuses = { - "online" : discord.Status.online, - "idle" : discord.Status.idle, - "dnd" : discord.Status.dnd, - "invisible" : discord.Status.invisible - } + "online": discord.Status.online, + "idle": discord.Status.idle, + "dnd": discord.Status.dnd, + "invisible": discord.Status.invisible + } - game = ctx.me.game + if len(ctx.bot.guilds) == 0: + await ctx.send_help() + return + game = ctx.bot.guilds[0].me.game try: status = statuses[status.lower()] @@ -441,12 +460,14 @@ class Core: @_set.command() @checks.is_owner() - @commands.guild_only() async def stream(self, ctx, streamer=None, *, stream_title=None): """Sets Red's streaming status Leaving both streamer and stream_title empty will clear it.""" - status = ctx.me.status + if len(ctx.bot.guilds) == 0: + await ctx.send_help() + return + status = ctx.bot.guilds[0].me.status if stream_title: stream_title = stream_title.strip()