Skip to content

Commit

Permalink
fix reboot logic
Browse files Browse the repository at this point in the history
  • Loading branch information
greeeen-dev committed Jun 6, 2024
1 parent e91b8ff commit 4eaec9e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cogs/sysmgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ async def upgrade(self, ctx, plugin='system', *, args=''):
with open('update_check/update.json', 'r') as file:
new = json.load(file)
if new['release'] > current['release'] or force:
available.append([new['version'], 'Release version', new['release'], -1])
available.append([new['version'], 'Release version', new['release'], -1, new['reboot']])
index = 0
for legacy in new['legacy']:
if (
Expand All @@ -970,7 +970,7 @@ async def upgrade(self, ctx, plugin='system', *, args=''):
)
) or force
):
available.append([legacy['version'], 'Legacy version', legacy['release'], index])
available.append([legacy['version'], 'Legacy version', legacy['release'], index, legacy['reboot']])
index += 1
update_available = len(available) >= 1
except:
Expand All @@ -990,15 +990,16 @@ async def upgrade(self, ctx, plugin='system', *, args=''):
release = available[selected][2]
version = available[selected][0]
legacy = available[selected][3] > -1
reboot = available[selected][4]
embed.title = f'{self.bot.ui_emojis.install} Update available'
embed.description = f'An update is available for Unifier!\n\nCurrent version: {current["version"]} (`{current["release"]}`)\nNew version: {version} (`{release}`)'
embed.remove_footer()
embed.colour = 0xffcc00
if legacy:
should_reboot = release >= (current['legacy'] if 'legacy' in current.keys() and
type(current['legacy']) is int else -1)
should_reboot = reboot >= (current['legacy'] if 'legacy' in current.keys() and
type(current['legacy']) is int else -1)
else:
should_reboot = release >= current['release']
should_reboot = reboot >= current['release']
if should_reboot:
embed.set_footer(text='The bot will need to reboot to apply the new update.')
selection = nextcord.ui.StringSelect(
Expand Down

0 comments on commit 4eaec9e

Please sign in to comment.