[V3] discord.Game -> discord.Activity (#1397)

* [V3] discord.Game -> discord.Activity

* Update userinfo to reference new enum
This commit is contained in:
Tobotimus 2018-03-13 09:41:37 +11:00 committed by Will
parent ccb322d08e
commit c7e8c95640
2 changed files with 23 additions and 23 deletions

View File

@ -216,24 +216,24 @@ class General:
created_on = _("{}\n({} days ago)").format(user_created, since_created) created_on = _("{}\n({} days ago)").format(user_created, since_created)
joined_on = _("{}\n({} days ago)").format(user_joined, since_joined) joined_on = _("{}\n({} days ago)").format(user_joined, since_joined)
game = _("Chilling in {} status").format(user.status) activity = _("Chilling in {} status").format(user.status)
if user.game is None: # Default status if user.activity is None: # Default status
pass pass
elif user.game.type == 0: # "Playing" status elif user.activity.type == discord.ActivityType.playing:
game = _("Playing {}").format(user.game.name) activity = _("Playing {}").format(user.activity.name)
elif user.game.type == 1: # "Streaming" status elif user.activity.type == discord.ActivityType.streaming:
game = _("Streaming [{}]({})").format(user.game.name, user.game.url) activity = _("Streaming [{}]({})").format(user.activity.name, user.activity.url)
elif user.game.type == 2: # "Listening" status elif user.activity.type == discord.ActivityType.listening:
game = _("Listening to {}").format(user.game.name) activity = _("Listening to {}").format(user.activity.name)
elif user.game.type == 3: # "Watching" status elif user.activity.type == discord.ActivityType.watching:
game = _("Watching {}").format(user.game.name) activity = _("Watching {}").format(user.activity.name)
if roles: if roles:
roles = ", ".join([x.name for x in roles]) roles = ", ".join([x.name for x in roles])
else: else:
roles = _("None") roles = _("None")
data = discord.Embed(description=game, colour=user.colour) data = discord.Embed(description=activity, colour=user.colour)
data.add_field(name=_("Joined Discord on"), value=created_on) data.add_field(name=_("Joined Discord on"), value=created_on)
data.add_field(name=_("Joined this guild on"), value=joined_on) data.add_field(name=_("Joined this guild on"), value=joined_on)
data.add_field(name=_("Roles"), value=roles, inline=False) data.add_field(name=_("Roles"), value=roles, inline=False)

View File

@ -397,7 +397,7 @@ class Core:
status = ctx.bot.guilds[0].me.status if len(ctx.bot.guilds) > 0 \ status = ctx.bot.guilds[0].me.status if len(ctx.bot.guilds) > 0 \
else discord.Status.online else discord.Status.online
for shard in ctx.bot.shards: for shard in ctx.bot.shards:
await ctx.bot.change_presence(status=status, game=game) await ctx.bot.change_presence(status=status, activity=game)
await ctx.send(_("Game set.")) await ctx.send(_("Game set."))
@_set.command(name="listening") @_set.command(name="listening")
@ -408,11 +408,11 @@ class Core:
status = ctx.bot.guilds[0].me.status if len(ctx.bot.guilds) > 0 \ status = ctx.bot.guilds[0].me.status if len(ctx.bot.guilds) > 0 \
else discord.Status.online else discord.Status.online
if listening: if listening:
listening = discord.Game(name=listening, type=2) activity = discord.Activity(name=listening, type=discord.ActivityType.listening)
else: else:
listening = None activity = None
for shard in ctx.bot.shards: for shard in ctx.bot.shards:
await ctx.bot.change_presence(status=status, game=listening) await ctx.bot.change_presence(status=status, activity=activity)
await ctx.send(_("Listening set.")) await ctx.send(_("Listening set."))
@_set.command(name="watching") @_set.command(name="watching")
@ -423,11 +423,11 @@ class Core:
status = ctx.bot.guilds[0].me.status if len(ctx.bot.guilds) > 0 \ status = ctx.bot.guilds[0].me.status if len(ctx.bot.guilds) > 0 \
else discord.Status.online else discord.Status.online
if watching: if watching:
watching = discord.Game(name=watching, type=3) activity = discord.Activity(name=watching, type=discord.ActivityType.watching)
else: else:
watching = None activity = None
for shard in ctx.bot.shards: for shard in ctx.bot.shards:
await ctx.bot.change_presence(status=status, game=watching) await ctx.bot.change_presence(status=status, activity=activity)
await ctx.send(_("Watching set.")) await ctx.send(_("Watching set."))
@_set.command() @_set.command()
@ -449,14 +449,14 @@ class Core:
"invisible": discord.Status.invisible "invisible": discord.Status.invisible
} }
game = ctx.bot.guilds[0].me.game if len(ctx.bot.guilds) > 0 else None game = ctx.bot.guilds[0].me.activity if len(ctx.bot.guilds) > 0 else None
try: try:
status = statuses[status.lower()] status = statuses[status.lower()]
except KeyError: except KeyError:
await ctx.send_help() await ctx.send_help()
else: else:
for shard in ctx.bot.shards: for shard in ctx.bot.shards:
await ctx.bot.change_presence(status=status, game=game) await ctx.bot.change_presence(status=status, activity=game)
await ctx.send(_("Status changed to %s.") % status) await ctx.send(_("Status changed to %s.") % status)
@_set.command() @_set.command()
@ -472,15 +472,15 @@ class Core:
stream_title = stream_title.strip() stream_title = stream_title.strip()
if "twitch.tv/" not in streamer: if "twitch.tv/" not in streamer:
streamer = "https://www.twitch.tv/" + streamer streamer = "https://www.twitch.tv/" + streamer
game = discord.Game(type=1, url=streamer, name=stream_title) activity = discord.Streaming(url=streamer, name=stream_title)
for shard in ctx.bot.shards: for shard in ctx.bot.shards:
await ctx.bot.change_presence(status=status, game=game) await ctx.bot.change_presence(status=status, activity=activity)
elif streamer is not None: elif streamer is not None:
await ctx.send_help() await ctx.send_help()
return return
else: else:
for shard in ctx.bot.shards: for shard in ctx.bot.shards:
await ctx.bot.change_presence(game=None, status=status) await ctx.bot.change_presence(activity=None, status=status)
await ctx.send(_("Done.")) await ctx.send(_("Done."))
@_set.command(name="username", aliases=["name"]) @_set.command(name="username", aliases=["name"])