diff options
author | 2019-09-25 20:21:06 -0600 | |
---|---|---|
committer | 2019-09-25 20:21:06 -0600 | |
commit | 1945439ffcb95621912930952cc25f84367a7621 (patch) | |
tree | de03fc664e96b6254bcab4de14c0d568b87a932a | |
parent | Merge pull request #452 from python-discord/hemlock-change-note-type (diff) | |
parent | Swapped Lambda for itemgetter (diff) |
Merge pull request #455 from python-discord/hemlock-free-fix
Free Command Fix
-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) |