Skip to content

Commit 83febb6

Browse files
committed
New command and improvements in bot update message interfaces.
1 parent b6284a0 commit 83febb6

File tree

3 files changed

+32
-18
lines changed

3 files changed

+32
-18
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
# [unreleased]
8+
9+
New command and improvements in bot update message interfaces.
10+
811
### Added
12+
- Added a changelog command to view the bot's changelog within discord.
13+
14+
### Changed
15+
- Update command now shows latest changes directly from the [CHANGELOG.md](https://modmail.tk/) in the repo.
16+
- Auto update messages also show latest changes from repo.
17+
918

1019
# v2.0.6
1120

bot.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
SOFTWARE.
2323
"""
2424

25-
__version__ = '2.0.6'
25+
__version__ = '2.0.7'
2626

2727
import asyncio
2828
import textwrap
@@ -39,6 +39,7 @@
3939
from core.api import Github, ModmailApiClient
4040
from core.thread import ThreadManager
4141
from core.config import ConfigManager
42+
from core.changelog import ChangeLog
4243

4344

4445
init()
@@ -166,12 +167,13 @@ async def on_ready(self):
166167
{Fore.CYAN}Guild ID: {self.guild.id if self.guild else 0}
167168
{line}
168169
""").strip())
169-
170+
170171
if not self.guild:
171172
print(Fore.RED + Style.BRIGHT + 'WARNING - The GUILD_ID provided does not exist!' + Style.RESET_ALL)
172173
else:
173174
await self.threads.populate_cache()
174175

176+
175177
async def process_modmail(self, message):
176178
"""Processes messages sent to the bot."""
177179

@@ -393,28 +395,27 @@ async def autoupdate_loop(self):
393395
data = await self.modmail_api.update_repository()
394396

395397

396-
em = discord.Embed(title='Updating bot', color=discord.Color.green())
398+
em = discord.Embed(color=discord.Color.green())
397399

398400
commit_data = data['data']
399401
user = data['user']
400-
em.set_author(name=user['username'], icon_url=user['avatar_url'], url=user['url'])
402+
em.set_author(name=user['username'] + ' - Updating Bot', icon_url=user['avatar_url'], url=user['url'])
401403
em.set_footer(text=f"Updating modmail v{self.version} -> v{metadata['latest_version']}")
402404

405+
changelog = await ChangeLog.from_repo(self)
406+
latest = changelog.latest_version
407+
em.description = latest.description
408+
for name, value in latest.fields.items():
409+
em.add_field(name=name, value=value)
410+
403411
if commit_data:
404-
em.description = 'Bot successfully updated, the bot will restart momentarily'
405412
message = commit_data['commit']['message']
406413
html_url = commit_data["html_url"]
407414
short_sha = commit_data['sha'][:6]
408415
em.add_field(name='Merge Commit', value=f"[`{short_sha}`]({html_url}) {message} - {user['username']}")
409416
print('Updating bot.')
410-
else:
411-
await asyncio.sleep(3600)
412-
continue
413-
414-
em.add_field(name='Latest Commit', value=await self.get_latest_updates(limit=1), inline=False)
415-
416-
channel = self.main_category.channels[0]
417-
await channel.send(embed=em)
417+
channel = self.main_category.channels[0]
418+
await channel.send(embed=em)
418419

419420
await asyncio.sleep(3600)
420421

cogs/utility.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,21 +248,25 @@ async def update(self, ctx):
248248

249249
commit_data = data['data']
250250
user = data['user']
251-
em.title = 'Success'
251+
em.title = None
252252
em.set_author(name=user['username'], icon_url=user['avatar_url'], url=user['url'])
253253
em.set_footer(text=f"Updating modmail v{self.bot.version} -> v{metadata['latest_version']}")
254254

255255
if commit_data:
256-
em.description = 'Bot successfully updated, the bot will restart momentarily'
256+
em.set_author(name=user['username'] + ' - Updating bot', icon_url=user['avatar_url'], url=user['url'])
257+
changelog = await ChangeLog.from_repo(self.bot)
258+
latest = changelog.latest_version
259+
em.description = latest.description
260+
for name, value in latest.fields.items():
261+
em.add_field(name=name, value=value)
257262
message = commit_data['commit']['message']
258263
html_url = commit_data["html_url"]
259264
short_sha = commit_data['sha'][:6]
260-
em.add_field(name='Merge Commit', value=f"[`{short_sha}`]({html_url}) {message} - {user['username']}")
265+
em.add_field(name='Merge Commit', value=f"[`{short_sha}`]({html_url})")
261266
else:
262267
em.description = 'Already up to date with master repository.'
263268

264-
em.add_field(name='Latest Commit', value=await self.bot.get_latest_updates(limit=1), inline=False)
265-
269+
266270
await ctx.send(embed=em)
267271

268272
@commands.command(name='status', aliases=['customstatus', 'presence'])

0 commit comments

Comments
 (0)