diff options
| author | 2018-12-04 20:04:32 +0100 | |
|---|---|---|
| committer | 2018-12-04 20:04:32 +0100 | |
| commit | 0a26624ff28734b7c6c7022004ba5dd30f4b38f9 (patch) | |
| tree | 51dbf72897d6ed83d57786c1869812e2d155d97a /bot | |
| parent | Merge pull request #86 from python-discord/bytecommander-aoc (diff) | |
| parent | Adapt code style according to review (diff) | |
Merge pull request #87 from python-discord/bytecommander-aoc2
Split .notifications toggle command into .subscribe and .unsubscribe
Diffstat (limited to 'bot')
| -rw-r--r-- | bot/seasons/christmas/adventofcode.py | 31 | 
1 files changed, 23 insertions, 8 deletions
| diff --git a/bot/seasons/christmas/adventofcode.py b/bot/seasons/christmas/adventofcode.py index a88ee4e7..58d083ab 100644 --- a/bot/seasons/christmas/adventofcode.py +++ b/bot/seasons/christmas/adventofcode.py @@ -138,23 +138,38 @@ class AdventOfCode:          await ctx.invoke(self.bot.get_command("help"), "adventofcode") -    @adventofcode_group.command(name="notifications", aliases=("notify", "notifs"), brief="Notifications for new days") -    async def aoc_notifications(self, ctx: commands.Context): +    @adventofcode_group.command( +        name="subscribe", +        aliases=("sub", "notifications", "notify", "notifs"), +        brief="Notifications for new days" +    ) +    async def aoc_subscribe(self, ctx: commands.Context):          """          Assign the role for notifications about new days being ready. +        """ +        role = ctx.guild.get_role(AocConfig.role_id) +        unsubscribe_command = f"{ctx.prefix}{ctx.command.root_parent} unsubscribe" -        Call the same command again to end notifications and remove the role. +        if role not in ctx.author.roles: +            await ctx.author.add_roles(role) +            await ctx.send("Okay! You have been __subscribed__ to notifications about new Advent of Code tasks. " +                           f"You can run `{unsubscribe_command}` to disable them again for you.") +        else: +            await ctx.send("Hey, you already are receiving notifications about new Advent of Code tasks. " +                           f"If you don't want them any more, run `{unsubscribe_command}` instead.") + +    @adventofcode_group.command(name="unsubscribe", aliases=("unsub",), brief="Notifications for new days") +    async def aoc_unsubscribe(self, ctx: commands.Context): +        """ +        Remove the role for notifications about new days being ready.          """          role = ctx.guild.get_role(AocConfig.role_id)          if role in ctx.author.roles:              await ctx.author.remove_roles(role) -            await ctx.send("Okay! You have been unsubscribed from notifications. If in future you want to" -                           " resubscribe just run this command again.") +            await ctx.send("Okay! You have been __unsubscribed__ from notifications about new Advent of Code tasks.")          else: -            await ctx.author.add_roles(role) -            await ctx.send("Okay! You have been subscribed to notifications about new Advent of Code tasks." -                           " To unsubscribe in future run the same command again.") +            await ctx.send("Hey, you don't even get any notifications about new Advent of Code tasks currently anyway.")      @adventofcode_group.command(name="countdown", aliases=("count", "c"), brief="Return time left until next day")      async def aoc_countdown(self, ctx: commands.Context): | 
