Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions bot/cogs/free.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
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

from bot.constants import Categories, Channels, Free, STAFF_ROLES
from bot.decorators import redirect_output


log = logging.getLogger(__name__)

TIMEOUT = Free.activity_timeout
Expand Down Expand Up @@ -51,10 +51,10 @@ async def free(self, ctx: Context, user: Member = None, seek: int = 2) -> None:
# 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:
Expand All @@ -80,7 +80,8 @@ async def free(self, ctx: Context, user: Member = None, seek: int = 2) -> None:
# 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)
Expand Down