WIP: Add UpdateChecker cog #14

Draft
cswimr wants to merge 37 commits from updatechecker into main
Showing only changes of commit 45fcc00cdb - Show all commits

View file

@ -75,12 +75,10 @@ class UpdateChecker(commands.Cog):
@tasks.loop(minutes=1) @tasks.loop(minutes=1)
async def bg_task(self): async def bg_task(self):
while True:
cog = self.bot.get_cog("Downloader") cog = self.bot.get_cog("Downloader")
if cog is not None: if cog is not None:
data = await self.conf.all() data = await self.conf.all()
repos = data["repos"] repos = data["repos"]
auto = data["auto"]
channel = data["gochannel"] channel = data["gochannel"]
use_embed = data["embed"] use_embed = data["embed"]
whitelist = data["whitelist"] whitelist = data["whitelist"]
@ -315,9 +313,8 @@ class UpdateChecker(commands.Cog):
if channel == 0: if channel == 0:
channel = "Direct Messages" channel = "Direct Messages"
else: else:
try:
channel = self.bot.get_channel(channel).name channel = self.bot.get_channel(channel).name
except: if channel is None:
channel = "Unknown" channel = "Unknown"
e.add_field(name="Update Channel", value=channel) e.add_field(name="Update Channel", value=channel)
await ctx.send(embed=e) await ctx.send(embed=e)
@ -325,9 +322,8 @@ class UpdateChecker(commands.Cog):
if channel == 0: if channel == 0:
channel = "Direct Messages" channel = "Direct Messages"
else: else:
try:
channel = self.bot.get_channel(channel).name channel = self.bot.get_channel(channel).name
except: if channel is None:
channel = "Unknown" channel = "Unknown"
message = ( message = (
"```css\n" "```css\n"
@ -363,7 +359,6 @@ class UpdateChecker(commands.Cog):
@whiteblacklist.group() @whiteblacklist.group()
async def whitelist(self, ctx): async def whitelist(self, ctx):
"""Whitelist certain repos from which to receive updates.""" """Whitelist certain repos from which to receive updates."""
pass
@whitelist.command(name="add") @whitelist.command(name="add")
async def whitelistadd(self, ctx, *repos: Repo): async def whitelistadd(self, ctx, *repos: Repo):
@ -396,7 +391,6 @@ class UpdateChecker(commands.Cog):
@whiteblacklist.group() @whiteblacklist.group()
async def blacklist(self, ctx): async def blacklist(self, ctx):
"""Blacklist certain repos from which to receive updates.""" """Blacklist certain repos from which to receive updates."""
pass
@blacklist.command(name="add") @blacklist.command(name="add")
async def blacklistadd(self, ctx, *repos: Repo): async def blacklistadd(self, ctx, *repos: Repo):
@ -430,7 +424,6 @@ class UpdateChecker(commands.Cog):
@update.group(name="task") @update.group(name="task")
async def _group_update_task(self, ctx): async def _group_update_task(self, ctx):
"""View the status of the task (the one checking for updates).""" """View the status of the task (the one checking for updates)."""
pass
@_group_update_task.command() @_group_update_task.command()
async def status(self, ctx): async def status(self, ctx):
@ -462,5 +455,5 @@ class UpdateChecker(commands.Cog):
message = "No error has been encountered." message = "No error has been encountered."
else: else:
ex = traceback.format_exception(type(e), e, e.__traceback__) ex = traceback.format_exception(type(e), e, e.__traceback__)
message = "An error has been encountered: ```py\n" + "".join(ex) + "```" message = "An error has been encountered:" + box("".join(ex), "py")
await ctx.send(message) await ctx.send(message)