From 08a6a1d2c9d36c90662851ef86f6fa9c77a382ae Mon Sep 17 00:00:00 2001 From: Evanroby Date: Sat, 23 May 2026 05:55:31 +0200 Subject: [PATCH] Add warning to `[p]set api` if <>s are included in secret (#6651) Co-authored-by: giplgwm <98342753+giplgwm@users.noreply.github.com> Co-authored-by: Jakub Kuczys --- redbot/core/core_commands.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/redbot/core/core_commands.py b/redbot/core/core_commands.py index 9541de9c6..d0368c8ec 100644 --- a/redbot/core/core_commands.py +++ b/redbot/core/core_commands.py @@ -3708,8 +3708,26 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): else: if ctx.bot_permissions.manage_messages: await ctx.message.delete() + + angle_bracket_warning = None + + for token_name, token in tokens.items(): + if token.startswith("<") and token.endswith(">"): + angle_bracket_warning = _( + "You may have failed to properly format your `{token_name}`. If you were told to enter a token" + " with an example such as `[p]set api {service} {token_name} `, and your {token_name}" + " was `HREDFGWE`, make sure to run `[p]set api {service} {token_name} HREDFGWE` and not " + "`[p]set api {service} {token_name} `." + ).format(token_name=token_name, service=service) + break + await ctx.bot.set_shared_api_tokens(service, **tokens) - await ctx.send(_("`{service}` API tokens have been set.").format(service=service)) + + message = _("`{service}` API tokens have been set.").format(service=service) + if angle_bracket_warning: + message += "\n\n" + _("**Warning:** ") + angle_bracket_warning + + await ctx.send(message) @_set_api.command(name="list") async def _set_api_list(self, ctx: commands.Context):