Skip to content

Commit

Permalink
update users on listing
Browse files Browse the repository at this point in the history
0 time is in /timeout user now as "cancel"
  • Loading branch information
solumath committed Apr 28, 2023
1 parent 15e2dcb commit 39ff9f2
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions cogs/timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ async def timeout_parse(self, inter, user, endtime, reason):
if not date:
try:
# check for positive timeout length
if float(endtime) <= 0:
if float(endtime) < 0:
await inter.send(Messages.timeout_negative_time)
return

Expand Down Expand Up @@ -276,16 +276,17 @@ async def timeout_list(
inter: disnake.ApplicationCommandInteraction,
):
"""List all timed out users"""
await self.update_timeout()

users = self.timeout_repo.get_timeout_users()
if not users:
await inter.send(Messages.timeout_list_none)
return

await self.timeout_embed_listing(users, "Timeout list", inter, inter.author)

@tasks.loop(time=time(12, 0, tzinfo=utils.get_local_zone()))
async def refresh_timeout(self):
"""Update timeout for users saved in db"""
async def update_timeout(self):
"""update all user's timeout in database and on server"""
users = self.timeout_repo.get_timeout_users()
guild = self.bot.get_guild(config.guild_id)

Expand All @@ -311,6 +312,11 @@ async def refresh_timeout(self):
elif current_timeout < end_timeout:
await member.timeout(until=user.end, reason=user.reason)

@tasks.loop(time=time(12, 0, tzinfo=utils.get_local_zone()))
async def refresh_timeout(self):
"""Update timeout for users saved in db"""
await self.update_timeout()

# send update
users = self.timeout_repo.get_timeout_users()
if users:
Expand Down

0 comments on commit 39ff9f2

Please sign in to comment.