Skip to content

Commit aaf2fc7

Browse files
committed
fix: AttributeError / lower mongo calls.
I had added a small bugfix aswell for pagination when an invalid config var was given. This happened to occur upon removing the `thread_auto_close` config.
1 parent 03ed1a7 commit aaf2fc7

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

cogs/utility.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -880,21 +880,26 @@ async def config_remove(self, ctx, *, key: str.lower):
880880
for recipient_id, items in tuple(closures.items()):
881881
if items.get("auto_close", False) is True:
882882
self.bot.config["closures"].pop(recipient_id)
883-
await self.config.update()
884883
thread = await self.bot.threads.find(recipient_id=int(recipient_id))
885884
if thread:
886885
await thread.cancel_closure(all=True)
887886
else:
888887
self.bot.config["closures"].pop(recipient_id)
889-
await self.config.update()
888+
# Only update config once after processing all closures
889+
await self.bot.config.update()
890890
else:
891-
embed = discord.Embed(
892-
title="Error",
893-
color=self.bot.error_color,
894-
description=f"{key} is an invalid key.",
895-
)
896-
valid_keys = [f"`{k}`" for k in sorted(keys)]
897-
embed.add_field(name="Valid keys", value=", ".join(valid_keys))
891+
embeds = []
892+
for names in zip_longest(*(iter(sorted(keys)),) * 15):
893+
description = "\n".join(f"`{name}`" for name in takewhile(lambda x: x is not None, names))
894+
embed = discord.Embed(
895+
title="Error - Invalid Key",
896+
color=self.bot.error_color,
897+
description=f"`{key}` is an invalid key.\n\n**Valid configuration keys:**\n{description}",
898+
)
899+
embeds.append(embed)
900+
901+
session = EmbedPaginatorSession(ctx, *embeds)
902+
return await session.run()
898903

899904
return await ctx.send(embed=embed)
900905

0 commit comments

Comments
 (0)