Skip to content

Commit 5649659

Browse files
committed
Failsafe for long changelogs
1 parent 1ae3cf6 commit 5649659

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

cogs/utility.py

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,8 +1902,10 @@ async def update(self, ctx, *, flag: str = ""):
19021902

19031903
embed.description = latest.description
19041904
for name, value in latest.fields.items():
1905+
if value > 200:
1906+
value = value[:200] + "..."
1907+
19051908
embed.add_field(name=name, value=value)
1906-
# message = commit_data['commit']['message']
19071909
html_url = commit_data["html_url"]
19081910
short_sha = commit_data["sha"][:6]
19091911
embed.add_field(name="Merge Commit", value=f"[`{short_sha}`]({html_url})")
@@ -1926,28 +1928,29 @@ async def update(self, ctx, *, flag: str = ""):
19261928

19271929
if res != "Already up to date.":
19281930
logger.info("Bot has been updated.")
1929-
if self.bot.hosting_method == HostingMethod.PM2:
1930-
embed = discord.Embed(
1931-
title="Bot has been updated",
1932-
color=self.bot.main_color,
1933-
)
1934-
embed.set_footer(
1935-
text=f"Updating Modmail v{self.bot.version} " f"-> v{latest.version}"
1936-
)
1937-
await ctx.send(embed=embed)
1938-
else:
1939-
embed = discord.Embed(
1940-
title="Bot has been updated and is logging out.",
1941-
description="If you do not have an auto-restart setup, please manually start the bot.",
1942-
color=self.bot.main_color,
1943-
)
1944-
embed.set_footer(
1945-
text=f"Updating Modmail v{self.bot.version} " f"-> v{latest.version}"
1931+
1932+
embed = discord.Embed(title="Bot has been updated", color=self.bot.main_color,)
1933+
embed.set_footer(
1934+
text=f"Updating Modmail v{self.bot.version} " f"-> v{latest.version}"
1935+
)
1936+
embed.description = latest.description
1937+
for name, value in latest.fields.items():
1938+
if value > 200:
1939+
value = value[:200] + "..."
1940+
1941+
embed.add_field(name=name, value=value)
1942+
1943+
if self.bot.hosting_method == HostingMethod.OTHER:
1944+
embed.description = (
1945+
"If you do not have an auto-restart setup, please manually start the bot.",
19461946
)
1947-
await ctx.send(embed=embed)
1947+
1948+
await ctx.send(embed=embed)
19481949
await self.bot.logout()
19491950
else:
1950-
embed = discord.Embed(title="Already up to date", description=desc, color=self.bot.main_color,)
1951+
embed = discord.Embed(
1952+
title="Already up to date", description=desc, color=self.bot.main_color,
1953+
)
19511954
await ctx.send(embed=embed)
19521955

19531956
@commands.command(hidden=True, name="eval")

0 commit comments

Comments
 (0)