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