fix(updatechecker): fixed error in the fetch_gitea_thumbnail method

This commit is contained in:
Seaswimmer 2024-01-07 19:51:18 +00:00
parent 88ee068cbd
commit 50180c6301
Signed by untrusted user: cswimr
GPG key ID: D74DDDDF420E13DF

View file

@ -257,7 +257,7 @@ class UpdateChecker(commands.Cog):
timeout = aiohttp.client.ClientTimeout(total=15) timeout = aiohttp.client.ClientTimeout(total=15)
try: try:
async with self.session.get(url, timeout=timeout) as response: async with self.session.get(url, timeout=timeout) as response:
data = await response.read() data = await response.json()
except (aiohttp.ClientError, asyncio.TimeoutError): except (aiohttp.ClientError, asyncio.TimeoutError):
return None return None
@ -265,12 +265,12 @@ class UpdateChecker(commands.Cog):
@commands.is_owner() @commands.is_owner()
@commands.group(name="cogupdater", aliases=["cu"]) @commands.group(name="cogupdater", aliases=["cu"])
async def update(self, ctx): async def update(self, ctx: commands.Context):
"""Group command for controlling the update checker cog.""" """Group command for controlling the update checker cog."""
@commands.is_owner() @commands.is_owner()
@update.command() @update.command()
async def auto(self, ctx): async def auto(self, ctx: commands.Context):
"""Changes automatic cog updates to the opposite setting.""" """Changes automatic cog updates to the opposite setting."""
# Was already inaccessible before I got here, so I'm just gonna leave it and look at it later -- Sea # Was already inaccessible before I got here, so I'm just gonna leave it and look at it later -- Sea
# auto = await self.conf.auto() # auto = await self.conf.auto()
@ -283,7 +283,7 @@ class UpdateChecker(commands.Cog):
@commands.is_owner() @commands.is_owner()
@update.command() @update.command()
async def channel(self, ctx, channel: discord.TextChannel = None): async def channel(self, ctx: commands.Context, channel: discord.TextChannel = None):
""" """
Sets a channel for update messages to go to. Sets a channel for update messages to go to.
@ -299,7 +299,7 @@ class UpdateChecker(commands.Cog):
@commands.is_owner() @commands.is_owner()
@update.command() @update.command()
async def settings(self, ctx): async def settings(self, ctx: commands.Context):
"""See settings for the Update Checker cog. """See settings for the Update Checker cog.
Right now, this shows whether the bot updates cogs automatically and what channel logs are sent to. Right now, this shows whether the bot updates cogs automatically and what channel logs are sent to.
@ -337,7 +337,7 @@ class UpdateChecker(commands.Cog):
@commands.is_owner() @commands.is_owner()
@update.command() @update.command()
async def embed(self, ctx): async def embed(self, ctx: commands.Context):
"""Toggles whether to use embeds or colorful codeblock messages when sending an update.""" """Toggles whether to use embeds or colorful codeblock messages when sending an update."""
c = await self.conf.embed() c = await self.conf.embed()
await self.conf.embed.set(not c) await self.conf.embed.set(not c)
@ -346,7 +346,7 @@ class UpdateChecker(commands.Cog):
@commands.is_owner() @commands.is_owner()
@update.group(name="list") @update.group(name="list")
async def whiteblacklist(self, ctx): async def whiteblacklist(self, ctx: commands.Context):
"""Whitelist/blacklist certain repositories from which to receive updates.""" """Whitelist/blacklist certain repositories from which to receive updates."""
if ctx.invoked_subcommand is None: if ctx.invoked_subcommand is None:
data = await self.conf.all() data = await self.conf.all()
@ -357,11 +357,11 @@ class UpdateChecker(commands.Cog):
) )
@whiteblacklist.group() @whiteblacklist.group()
async def whitelist(self, ctx): async def whitelist(self, ctx: commands.Context):
"""Whitelist certain repos from which to receive updates.""" """Whitelist certain repos from which to receive updates."""
@whitelist.command(name="add") @whitelist.command(name="add")
async def whitelistadd(self, ctx, *repos: Repo): async def whitelistadd(self, ctx: commands.Context, *repos: Repo):
"""Add repos to the whitelist""" """Add repos to the whitelist"""
data = await self.conf.whitelist() data = await self.conf.whitelist()
ds = set(data) ds = set(data)
@ -371,7 +371,7 @@ class UpdateChecker(commands.Cog):
await ctx.send(f"Whitelist update successful: {humanize_list(tuple(map(inline, ss)))}") await ctx.send(f"Whitelist update successful: {humanize_list(tuple(map(inline, ss)))}")
@whitelist.command(name="remove") @whitelist.command(name="remove")
async def whitelistremove(self, ctx, *repos: Repo): async def whitelistremove(self, ctx: commands.Context, *repos: Repo):
"""Remove repos from the whitelist""" """Remove repos from the whitelist"""
data = await self.conf.whitelist() data = await self.conf.whitelist()
ds = set(data) ds = set(data)
@ -383,17 +383,17 @@ class UpdateChecker(commands.Cog):
) )
@whitelist.command(name="clear") @whitelist.command(name="clear")
async def whitelistclear(self, ctx): async def whitelistclear(self, ctx: commands.Context):
"""Removes all repos from the whitelist""" """Removes all repos from the whitelist"""
await self.conf.whitelist.set([]) await self.conf.whitelist.set([])
await ctx.send("Whitelist update successful") await ctx.send("Whitelist update successful")
@whiteblacklist.group() @whiteblacklist.group()
async def blacklist(self, ctx): async def blacklist(self, ctx: commands.Context):
"""Blacklist certain repos from which to receive updates.""" """Blacklist certain repos from which to receive updates."""
@blacklist.command(name="add") @blacklist.command(name="add")
async def blacklistadd(self, ctx, *repos: Repo): async def blacklistadd(self, ctx: commands.Context, *repos: Repo):
"""Add repos to the blacklist""" """Add repos to the blacklist"""
data = await self.conf.blacklist() data = await self.conf.blacklist()
ds = set(data) ds = set(data)
@ -403,7 +403,7 @@ class UpdateChecker(commands.Cog):
await ctx.send(f"Backlist update successful: {humanize_list(tuple(map(inline, ss)))}") await ctx.send(f"Backlist update successful: {humanize_list(tuple(map(inline, ss)))}")
@blacklist.command(name="remove") @blacklist.command(name="remove")
async def blacklistremove(self, ctx, *repos: Repo): async def blacklistremove(self, ctx: commands.Context, *repos: Repo):
"""Remove repos from the blacklist""" """Remove repos from the blacklist"""
data = await self.conf.blacklist() data = await self.conf.blacklist()
ds = set(data) ds = set(data)
@ -415,18 +415,18 @@ class UpdateChecker(commands.Cog):
) )
@blacklist.command(name="clear") @blacklist.command(name="clear")
async def blacklistclear(self, ctx): async def blacklistclear(self, ctx: commands.Context):
"""Removes all repos from the blacklist""" """Removes all repos from the blacklist"""
await self.conf.blacklist.set([]) await self.conf.blacklist.set([])
await ctx.send("Blacklist update successful") await ctx.send("Blacklist update successful")
@commands.is_owner() @commands.is_owner()
@update.group(name="task") @update.group(name="task")
async def _group_update_task(self, ctx): async def _group_update_task(self, ctx: commands.Context):
"""View the status of the task (the one checking for updates).""" """View the status of the task (the one checking for updates)."""
@_group_update_task.command() @_group_update_task.command()
async def status(self, ctx): async def status(self, ctx: commands.Context):
"""Get the current status of the update task.""" """Get the current status of the update task."""
message = "Task is currently " message = "Task is currently "
cancelled = self.task.cancelled() cancelled = self.task.cancelled()
@ -443,11 +443,11 @@ class UpdateChecker(commands.Cog):
except asyncio.exceptions.InvalidStateError: except asyncio.exceptions.InvalidStateError:
message += " No error has been encountered." message += " No error has been encountered."
else: else:
message += " An error has been encountered. Please run `[p]cogupdater task error` and report it to SeaswimmerTheFsh (.seasw) on the help server." message += f" An error has been encountered. Please run `{ctx.prefix}cogupdater task error` and report it to SeaswimmerTheFsh (.seasw) on the help server."
await ctx.send(message) await ctx.send(message)
@_group_update_task.command() @_group_update_task.command()
async def error(self, ctx): async def error(self, ctx: commands.Context):
"""Gets the latest error of the update task.""" """Gets the latest error of the update task."""
try: try:
e = self.task.exception() e = self.task.exception()