From 34908ceeec6368923e465e1cfdcec6a86d3bed67 Mon Sep 17 00:00:00 2001 From: granny <43185817+granny@users.noreply.github.com> Date: Wed, 13 Jan 2021 16:18:12 -0800 Subject: [PATCH] if the embed is above max size, truncate fields (#12) --- cogs/timings.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cogs/timings.py b/cogs/timings.py index b743439..0608b2a 100644 --- a/cogs/timings.py +++ b/cogs/timings.py @@ -237,12 +237,19 @@ class Timings(commands.Cog): await message.reply(embed=embed_var) return + if unchecked > 0: + embed_var.description = "||" + str(unchecked) + " missing configuration optimizations.||" + issue_count = len(embed_var.fields) + field_at_index = 24 if issue_count >= 25: embed_var.insert_field_at(index=24, name="Plus " + str(issue_count - 24) + " more recommendations", value="Create a new timings report after resolving some of the above issues to see more.") - if unchecked > 0: - embed_var.description = "||" + str(unchecked) + " missing configuration optimizations.||" + while len(embed_var) > 6000: + embed_var.insert_field_at(index=field_at_index, name="Plus " + str(issue_count - field_at_index) + " more recommendations", + value="Create a new timings report after resolving some of the above issues to see more.") + del embed_var._fields[(field_at_index + 1):] + field_at_index-=1 await message.reply(embed=embed_var) def eval_field(embed_var, option, option_name, unchecked, plugins, server_properties, bukkit, spigot, paper, purpur):