aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Leon Sandøy <[email protected]>2020-06-06 12:37:01 +0200
committerGravatar Leon Sandøy <[email protected]>2020-06-06 12:37:01 +0200
commit40a774e0bb6ed8947a17fe0116e2f1dc0cf89156 (patch)
treece3e5158084d1750d156b68bfffd41344b14f0dd
parentStore epoch timestamps instead of strings. (diff)
Fix potential race condition.
Instead of first checking if the channel.id exists and then checking what it is, we just do a single API call, to prevent cases where something fucky might happen inbetween the first and the second call.
-rw-r--r--bot/cogs/help_channels.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/bot/cogs/help_channels.py b/bot/cogs/help_channels.py
index dd3e3cb8b..01c38b408 100644
--- a/bot/cogs/help_channels.py
+++ b/bot/cogs/help_channels.py
@@ -548,20 +548,20 @@ class HelpChannels(Scheduler, commands.Cog):
self.bot.stats.incr(f"help.dormant_calls.{caller}")
- if await self.claim_times.contains(channel.id):
- claimed_timestamp = await self.claim_times.get(channel.id)
+ claimed_timestamp = await self.claim_times.get(channel.id)
+ if claimed_timestamp:
claimed = datetime.fromtimestamp(claimed_timestamp)
in_use_time = datetime.utcnow() - claimed
self.bot.stats.timing("help.in_use_time", in_use_time)
- if await self.unanswered.contains(channel.id):
- if await self.unanswered.get(channel.id):
+ unanswered = await self.unanswered.get(channel.id)
+ if unanswered is not None:
+ if unanswered:
self.bot.stats.incr("help.sessions.unanswered")
else:
self.bot.stats.incr("help.sessions.answered")
log.trace(f"Position of #{channel} ({channel.id}) is actually {channel.position}.")
-
log.trace(f"Sending dormant message for #{channel} ({channel.id}).")
embed = discord.Embed(description=DORMANT_MSG)
await channel.send(embed=embed)