From c9dc67f0453ded99a77ad8c5fe7d8b55bca60fe7 Mon Sep 17 00:00:00 2001 From: Desktop Date: Mon, 30 Oct 2023 15:45:43 -0400 Subject: [PATCH 1/5] Added discord timestamps --- redbot/cogs/streams/streamtypes.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/redbot/cogs/streams/streamtypes.py b/redbot/cogs/streams/streamtypes.py index c95a05b5b6e..5c7290eb4be 100644 --- a/redbot/cogs/streams/streamtypes.py +++ b/redbot/cogs/streams/streamtypes.py @@ -221,17 +221,16 @@ async def make_embed(self, data): if vid_data["liveStreamingDetails"].get("scheduledStartTime", None) is not None: if "actualStartTime" not in vid_data["liveStreamingDetails"]: start_time = parse_time(vid_data["liveStreamingDetails"]["scheduledStartTime"]) + start_time_unix = time.mktime(start_time.timetuple()) start_in = start_time - datetime.now(timezone.utc) if start_in.total_seconds() > 0: - embed.description = _("This stream will start in {time}").format( - time=humanize_timedelta( - timedelta=timedelta(minutes=start_in.total_seconds() // 60) - ) # getting rid of seconds + embed.description = _("This stream will start ").format( + time=int(start_time_unix) ) else: - embed.description = _( - "This stream was scheduled for {min} minutes ago" - ).format(min=round((start_in.total_seconds() * -1) // 60)) + embed.description = _("This stream was scheduled for ").format( + time=int(start_time_unix) + ) embed.timestamp = start_time is_schedule = True else: From c90e076b022f09d87308a0556a96600d1a60c3e1 Mon Sep 17 00:00:00 2001 From: Desktop Date: Tue, 31 Oct 2023 21:11:05 -0400 Subject: [PATCH 2/5] Add warning to [p]set api if <>s are included in secret --- redbot/core/core_commands.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/redbot/core/core_commands.py b/redbot/core/core_commands.py index 6483de26adb..9a97d20f195 100644 --- a/redbot/core/core_commands.py +++ b/redbot/core/core_commands.py @@ -3633,7 +3633,20 @@ async def _set_api( else: if ctx.bot_permissions.manage_messages: await ctx.message.delete() + print(tokens) + embed = discord.Embed() + for dict_key, token in tokens.items(): + if token.startswith("<") and token.endswith(">"): + angle_bracket_warning = _( + "Your `{dict_key}` was set including the <> symbols. If this was an accident you may experience" + " issues with `{service}`. In that case, please try setting your `{dict_key}` again with" + " the < and > removed" + ).format(dict_key=dict_key, service=service) + log.warning(angle_bracket_warning) + embed.add_field(name="Warning", value=angle_bracket_warning) await ctx.bot.set_shared_api_tokens(service, **tokens) + if embed: + await ctx.send(embed=embed) await ctx.send(_("`{service}` API tokens have been set.").format(service=service)) @_set_api.command(name="list") From 17f65f48aebb25afb36a4623713a61ed3be2b2bc Mon Sep 17 00:00:00 2001 From: Desktop Date: Tue, 31 Oct 2023 21:24:56 -0400 Subject: [PATCH 3/5] revert to original --- redbot/cogs/streams/streamtypes.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/redbot/cogs/streams/streamtypes.py b/redbot/cogs/streams/streamtypes.py index 5c7290eb4be..c95a05b5b6e 100644 --- a/redbot/cogs/streams/streamtypes.py +++ b/redbot/cogs/streams/streamtypes.py @@ -221,16 +221,17 @@ async def make_embed(self, data): if vid_data["liveStreamingDetails"].get("scheduledStartTime", None) is not None: if "actualStartTime" not in vid_data["liveStreamingDetails"]: start_time = parse_time(vid_data["liveStreamingDetails"]["scheduledStartTime"]) - start_time_unix = time.mktime(start_time.timetuple()) start_in = start_time - datetime.now(timezone.utc) if start_in.total_seconds() > 0: - embed.description = _("This stream will start ").format( - time=int(start_time_unix) + embed.description = _("This stream will start in {time}").format( + time=humanize_timedelta( + timedelta=timedelta(minutes=start_in.total_seconds() // 60) + ) # getting rid of seconds ) else: - embed.description = _("This stream was scheduled for ").format( - time=int(start_time_unix) - ) + embed.description = _( + "This stream was scheduled for {min} minutes ago" + ).format(min=round((start_in.total_seconds() * -1) // 60)) embed.timestamp = start_time is_schedule = True else: From 2b8296c155067095a4ba85769251f6116d9a01a7 Mon Sep 17 00:00:00 2001 From: Desktop Date: Tue, 31 Oct 2023 21:27:48 -0400 Subject: [PATCH 4/5] Add warning to [p]set api if <>s are included in secret --- redbot/core/core_commands.py | 1 - 1 file changed, 1 deletion(-) diff --git a/redbot/core/core_commands.py b/redbot/core/core_commands.py index 9a97d20f195..33424949c84 100644 --- a/redbot/core/core_commands.py +++ b/redbot/core/core_commands.py @@ -3633,7 +3633,6 @@ async def _set_api( else: if ctx.bot_permissions.manage_messages: await ctx.message.delete() - print(tokens) embed = discord.Embed() for dict_key, token in tokens.items(): if token.startswith("<") and token.endswith(">"): From b57e275e79b086a9a0e04e22617fc1cc0ffefeee Mon Sep 17 00:00:00 2001 From: Desktop Date: Thu, 2 Nov 2023 14:03:22 -0400 Subject: [PATCH 5/5] Corrected for PR comments --- redbot/core/core_commands.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/redbot/core/core_commands.py b/redbot/core/core_commands.py index 33424949c84..e5bf3675724 100644 --- a/redbot/core/core_commands.py +++ b/redbot/core/core_commands.py @@ -3634,19 +3634,21 @@ async def _set_api( if ctx.bot_permissions.manage_messages: await ctx.message.delete() embed = discord.Embed() - for dict_key, token in tokens.items(): + for api_service_name, token in tokens.items(): if token.startswith("<") and token.endswith(">"): - angle_bracket_warning = _( - "Your `{dict_key}` was set including the <> symbols. If this was an accident you may experience" - " issues with `{service}`. In that case, please try setting your `{dict_key}` again with" - " the < and > removed" - ).format(dict_key=dict_key, service=service) + angle_bracket_warning = ( + "You may have failed to properly format your {api_service_name}. If you were told to enter a key" + " with an example such as [p]set api {service} api_key , and your API key" + " was HREDFGWE, make sure to run [p]set api {service} api_key HREDFGWE, and not " + " [p]set api {service} api_key " + ).format(api_service_name=api_service_name, service=service) log.warning(angle_bracket_warning) - embed.add_field(name="Warning", value=angle_bracket_warning) + embed.add_field(name=_("Warning"), value=_(angle_bracket_warning)) await ctx.bot.set_shared_api_tokens(service, **tokens) - if embed: - await ctx.send(embed=embed) - await ctx.send(_("`{service}` API tokens have been set.").format(service=service)) + await ctx.send( + _("`{service}` API tokens have been set.").format(service=service), + embed=embed if len(embed.fields) > 0 else None, + ) @_set_api.command(name="list") async def _set_api_list(self, ctx: commands.Context):