diff options
| author | 2019-09-26 13:04:59 -0500 | |
|---|---|---|
| committer | 2019-09-26 13:04:59 -0500 | |
| commit | ce75b2ba7187146ba1b15158a6c5f84b2fed6116 (patch) | |
| tree | c431b8427b30e74b84afa55743e1c0b59a9327db | |
| parent | Remove infraction reason from infraction confirmation (diff) | |
| parent | Merge pull request #455 from python-discord/hemlock-free-fix (diff) | |
Merge branch 'master' into minor-moderation-mods
| -rw-r--r-- | bot/cogs/free.py | 9 | 
1 files changed, 5 insertions, 4 deletions
| diff --git a/bot/cogs/free.py b/bot/cogs/free.py index 167fab319..269c5c1b9 100644 --- a/bot/cogs/free.py +++ b/bot/cogs/free.py @@ -1,5 +1,6 @@  import logging  from datetime import datetime +from operator import itemgetter  from discord import Colour, Embed, Member, utils  from discord.ext.commands import Bot, Cog, Context, command @@ -7,7 +8,6 @@ from discord.ext.commands import Bot, Cog, Context, command  from bot.constants import Categories, Channels, Free, STAFF_ROLES  from bot.decorators import redirect_output -  log = logging.getLogger(__name__)  TIMEOUT = Free.activity_timeout @@ -51,10 +51,10 @@ class Free(Cog):              # the command was invoked in              if channel.id == ctx.channel.id:                  messages = await channel.history(limit=seek).flatten() -                msg = messages[seek-1] +                msg = messages[seek - 1]              # Otherwise get last message              else: -                msg = await channel.history(limit=1).next()   # noqa (False positive) +                msg = await channel.history(limit=1).next()  # noqa (False positive)              inactive = (datetime.utcnow() - msg.created_at).seconds              if inactive > TIMEOUT: @@ -80,7 +80,8 @@ class Free(Cog):              # Sort channels in descending order by seconds              # Get position in list, inactivity, and channel object              # For each channel, add to embed.description -            for i, (inactive, channel) in enumerate(sorted(free_channels, reverse=True), 1): +            sorted_channels = sorted(free_channels, key=itemgetter(0), reverse=True) +            for i, (inactive, channel) in enumerate(sorted_channels, 1):                  minutes, seconds = divmod(inactive, 60)                  if minutes > 59:                      hours, minutes = divmod(minutes, 60) | 
