Fix game command empty argument. (#3630)

This commit is contained in:
Stonedestroyer 2020-02-29 15:35:44 +01:00 committed by GitHub
parent e0de25ed65
commit b52c838018
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1079,21 +1079,19 @@ class Core(commands.Cog, CoreLogic):
async def _game(self, ctx: commands.Context, *, game: str = None):
"""Sets [botname]'s playing status"""
if len(game) > 128:
await ctx.send("The maximum length of game descriptions is 128 characters.")
if game:
if len(game) > 128:
await ctx.send("The maximum length of game descriptions is 128 characters.")
return
game = discord.Game(name=game)
else:
if game:
game = discord.Game(name=game)
else:
game = None
status = (
ctx.bot.guilds[0].me.status if len(ctx.bot.guilds) > 0 else discord.Status.online
)
await ctx.bot.change_presence(status=status, activity=game)
if game:
await ctx.send(_("Status set to ``Playing {game.name}``.").format(game=game))
else:
await ctx.send(_("Game cleared."))
game = None
status = ctx.bot.guilds[0].me.status if len(ctx.bot.guilds) > 0 else discord.Status.online
await ctx.bot.change_presence(status=status, activity=game)
if game:
await ctx.send(_("Status set to ``Playing {game.name}``.").format(game=game))
else:
await ctx.send(_("Game cleared."))
@_set.command(name="listening")
@checks.bot_in_a_guild()