Skip to content

Commit fd6dde5

Browse files
committed
Add urls that point to the specified version in the changelog
1 parent 4d81de7 commit fd6dde5

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

cogs/utility.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,11 @@ async def help_(self, ctx, *, command: str = None):
175175
async def changelog(self, ctx):
176176
"""Show a paginated changelog of the bot."""
177177
changelog = await Changelog.from_url(self.bot)
178-
paginator = PaginatorSession(ctx, *changelog.embeds)
179-
await paginator.run()
178+
try:
179+
paginator = PaginatorSession(ctx, *changelog.embeds)
180+
await paginator.run()
181+
except:
182+
await ctx.send(changelog.CHANGELOG_URL)
180183

181184
@commands.command(aliases=['bot', 'info'])
182185
@checks.has_permissions(PermissionLevel.REGULAR)

core/changelog.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ def parse(self) -> None:
5959
else:
6060
self.fields[curr_action] += line + '\n'
6161

62+
@property
63+
def url(self) -> str:
64+
return Changelog.CHANGELOG_URL + '#v' + self.version.replace('.', '')
65+
6266
@property
6367
def embed(self) -> Embed:
6468
"""
@@ -68,6 +72,7 @@ def embed(self) -> Embed:
6872
embed.set_author(
6973
name=f'v{self.version} - Changelog',
7074
icon_url=self.bot.user.avatar_url,
75+
url=self.url
7176
)
7277

7378
for name, value in self.fields.items():
@@ -99,14 +104,16 @@ class Changelog:
99104
100105
Class Attributes
101106
----------------
102-
CHANGELOG_URL : str
107+
RAW_CHANGELOG_URL : str
103108
The URL to Modmail changelog.
104109
VERSION_REGEX : re.Pattern
105110
The regex used to parse the versions.
106111
"""
112+
113+
107114

108-
CHANGELOG_URL = ('https://raw.githubusercontent.com/'
109-
'kyb3r/modmail/master/CHANGELOG.md')
115+
RAW_CHANGELOG_URL = 'https://raw.githubusercontent.com/kyb3r/modmail/master/CHANGELOG.md'
116+
CHANGELOG_URL = 'https://github.com/kyb3r/modmail/blob/master/CHANGELOG.md'
110117
VERSION_REGEX = re.compile(r'# (v\d+\.\d+\.\d+)([\S\s]*?(?=# v|$))')
111118

112119
def __init__(self, bot: Bot, text: str):
@@ -139,14 +146,14 @@ async def from_url(cls, bot: Bot, url: str = '') -> 'Changelog':
139146
bot : Bot
140147
The Modmail bot.
141148
url : str, optional
142-
Defaults to `CHANGELOG_URL`.
149+
Defaults to `RAW_CHANGELOG_URL`.
143150
The URL to the changelog.
144151
145152
Returns
146153
-------
147154
Changelog
148155
The newly created `Changelog` parsed from the `url`.
149156
"""
150-
url = url or cls.CHANGELOG_URL
157+
url = url or cls.RAW_CHANGELOG_URL
151158
resp = await bot.session.get(url)
152159
return cls(bot, await resp.text())

0 commit comments

Comments
 (0)