fix timestamp selection

This commit is contained in:
Nexus 2023-11-12 23:25:17 +00:00
parent b98651e77a
commit 3ebea2b289
Signed by: nex
GPG key ID: 0FA334385D0B689F

View file

@ -1128,15 +1128,17 @@ class OtherCog(commands.Cog):
) )
else: else:
parsed_qs = parse_qs(url) parsed_qs = parse_qs(url)
if "t" in parsed_qs and parsed_qs["t"] and parsed_qs["t"][0].isdigit(): if "t" in parsed_qs and parsed_qs['t']:
# Assume is timestamp # Assume is timestamp
timestamp = round(float(parsed_qs["t"][0])) try:
end_timestamp = None timestamp, end_timestamp = map(round, map(float, parsed_qs["t"]))
if len(parsed_qs["t"]) >= 2:
end_timestamp = round(float(parsed_qs["t"][1]))
if end_timestamp < timestamp: if end_timestamp < timestamp:
end_timestamp, timestamp = reversed((end_timestamp, timestamp)) timestamp, end_timestamp = reversed((timestamp, end_timestamp))
_end = "to %s" % end_timestamp if len(parsed_qs["t"]) == 2 else "onward" except ValueError:
timestamp = round(float(parsed_qs["t"][0]))
end_timestamp = None
_end = "to %s" % end_timestamp if end_timestamp is not None else "onward"
embed = discord.Embed( embed = discord.Embed(
title="Trimming...", title="Trimming...",
description=f"Trimming from {timestamp} seconds {_end}.\nThis may take a while.", description=f"Trimming from {timestamp} seconds {_end}.\nThis may take a while.",