aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Daniel Brown <[email protected]>2019-09-25 13:34:16 -0500
committerGravatar Daniel Brown <[email protected]>2019-09-25 13:34:16 -0500
commitbfb32b95c12a465b60943e527e83bd7d5fdc4b95 (patch)
treef43e5871075b2936da72bae13b571101c6ab89e3
parentMerge pull request #452 from python-discord/hemlock-change-note-type (diff)
Free Command Fix
- Fixed bug where if two channels had the same last message timestamp the command would error out. Signed-off-by: Daniel Brown <[email protected]>
-rw-r--r--bot/cogs/free.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/bot/cogs/free.py b/bot/cogs/free.py
index 167fab319..ec8834240 100644
--- a/bot/cogs/free.py
+++ b/bot/cogs/free.py
@@ -7,7 +7,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 +50,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 +79,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):
+ for i, (inactive, channel) in enumerate(
+ sorted(free_channels, key=lambda free_channel: free_channel[0], reverse=True), 1):
minutes, seconds = divmod(inactive, 60)
if minutes > 59:
hours, minutes = divmod(minutes, 60)