aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Chris <[email protected]>2021-04-01 19:18:51 +0100
committerGravatar Chris <[email protected]>2021-04-01 19:18:51 +0100
commite07ebebfcbbbe4e530b9bf106e2aa5d2e7ad9838 (patch)
treedca628d0a7eb7609d120f80b375f2a6c14c53781
parentUpdate schedule_at() to work with tz aware date times (diff)
Use tz aware timestamps and refactor for readibility - Stream cog
-rw-r--r--bot/exts/moderation/stream.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/bot/exts/moderation/stream.py b/bot/exts/moderation/stream.py
index 4a624ba2c..50ed01e78 100644
--- a/bot/exts/moderation/stream.py
+++ b/bot/exts/moderation/stream.py
@@ -87,9 +87,7 @@ class Stream(commands.Cog):
log.trace(f"Attempting to give temporary streaming permission to {member} ({member.id}).")
# If duration is none then calculate default duration
if duration is None:
- duration = arrow.utcnow() + timedelta(
- minutes=VideoPermission.default_permission_duration
- )
+ duration = arrow.utcnow() + timedelta(minutes=VideoPermission.default_permission_duration)
# Check if the member already has streaming permission
already_allowed = any(Roles.video == role.id for role in member.roles)
@@ -99,7 +97,7 @@ class Stream(commands.Cog):
return
# Schedule task to remove streaming permission from Member and add it to task cache
- self.scheduler.schedule_at(duration.naive, member.id, self._revoke_streaming_permission(member))
+ self.scheduler.schedule_at(duration, member.id, self._revoke_streaming_permission(member))
await self.task_cache.set(member.id, Arrow.fromdatetime(duration).timestamp())
await member.add_roles(discord.Object(Roles.video), reason="Temporary streaming access granted")
@@ -134,7 +132,7 @@ class Stream(commands.Cog):
await member.add_roles(discord.Object(Roles.video), reason="Permanent streaming access granted")
await ctx.send(f"{Emojis.check_mark} Permanently granted {member.mention} the permission to stream.")
- log.debug(f"Successfully given {member} ({member.id}) permanent streaming permission.")
+ log.debug(f"Successfully gave {member} ({member.id}) permanent streaming permission.")
@commands.command(aliases=("unstream", "rstream"))
@commands.has_any_role(*STAFF_ROLES)