Skip to content

Commit 3207ba8

Browse files
committed
Fix selfhosted autoupdates
1 parent e04347c commit 3207ba8

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

cogs/utility.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ async def update(self, ctx):
241241

242242
if metadata['latest_version'] == self.bot.version:
243243
data = await self.bot.modmail_api.get_user_info()
244-
if not data['error']:
244+
if not data.get('error'):
245245
user = data['user']
246246
em.set_author(name=user['username'], icon_url=user['avatar_url'], url=user['url'])
247247
else:

core/clients.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,14 @@ async def post_log(self, channel_id, payload):
283283
async def update_repository(self):
284284
user = await Github.login(self.app)
285285
data = await user.update_repository()
286-
return {'data': data}
286+
return {
287+
'data': data,
288+
'user': {
289+
'username': user.username,
290+
'avatar_url': user.avatar_url,
291+
'url': user.url
292+
}
293+
}
287294

288295
async def get_user_info(self):
289296
user = await Github.login(self.app)

core/decorators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ async def wrapper(self, ctx, *args, **kwargs):
1515
def auth_required(func):
1616
@functools.wraps(func)
1717
async def wrapper(self, ctx, *args, **kwargs):
18-
if self.bot.selfhosting and self.bot.config.get('github_access_token') or self.bot.config.get('modmail_api_token'):
18+
if self.bot.selfhosted and self.bot.config.get('github_access_token') or self.bot.config.get('modmail_api_token'):
1919
return await func(self, ctx, *args, **kwargs)
2020

2121

2222
em = discord.Embed(
2323
color=discord.Color.red(),
2424
title='Unauthorized',
25-
description='You can only use this command if you have a configured `MODMAIL_API_TOKEN`. Get your token from https://dashboard.modmail.tk' if not self.bot.selfhosting else 'You can only use this command if you have a configured `GITHUB_ACCESS_TOKEN`. Get a personal access token from developer settings.'
25+
description='You can only use this command if you have a configured `MODMAIL_API_TOKEN`. Get your token from https://dashboard.modmail.tk' if not self.bot.selfhosted else 'You can only use this command if you have a configured `GITHUB_ACCESS_TOKEN`. Get a personal access token from developer settings.'
2626
)
2727
await ctx.send(embed=em)
2828
return wrapper

0 commit comments

Comments
 (0)