mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-07 11:48:55 -05:00
Handle time innacuracy by warning owner (#2036)
* handle time innacuracy by warning owner * Fix typo and add space
This commit is contained in:
parent
aa69dd381f
commit
bda7e08208
@ -106,6 +106,7 @@ class RedBase(BotBase, RPCMixin):
|
||||
|
||||
self.counter = Counter()
|
||||
self.uptime = None
|
||||
self.checked_time_accuracy = None
|
||||
self.color = discord.Embed.Empty # This is needed or color ends up 0x000000
|
||||
|
||||
self.main_dir = bot_dir
|
||||
|
||||
@ -256,6 +256,20 @@ def init_events(bot, cli_flags):
|
||||
async def on_message(message):
|
||||
bot.counter["messages_read"] += 1
|
||||
await bot.process_commands(message)
|
||||
discord_now = message.created_at
|
||||
if (
|
||||
not bot.checked_time_accuracy
|
||||
or (discord_now - timedelta(minutes=60)) > bot.checked_time_accuracy
|
||||
):
|
||||
system_now = datetime.datetime.utcnow()
|
||||
diff = abs((discord_now - system_now).total_seconds)
|
||||
if diff > 60:
|
||||
log.warn(
|
||||
"Detected significant difference (%d seconds) in system clock to discord's clock."
|
||||
" Any time sensitive code may fail.",
|
||||
diff,
|
||||
)
|
||||
bot.checked_time_accuracy = discord_now
|
||||
|
||||
@bot.event
|
||||
async def on_resumed():
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user