vanity_url: Fix crash when editing a guild (#96)

This commit is contained in:
TSRBerry 2024-04-14 15:17:18 +02:00 committed by GitHub
parent 7c4a57d289
commit b2cda3fe85
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 4 deletions

View File

@ -1,4 +1,5 @@
from discord import Guild
from discord.errors import Forbidden
from discord.ext import tasks
from discord.ext.commands import Cog
@ -14,9 +15,14 @@ class VanityUrl(Cog):
async def update_vanity_code(self, guild: Guild, code: str):
if "VANITY_URL" in guild.features and guild.vanity_url_code != code:
await guild.edit(
reason="Configured vanity code was different", vanity_code=code
)
try:
await guild.edit(
reason="Configured vanity code was different", vanity_code=code
)
except Forbidden:
self.bot.log.exception(f"Not allowed to edit vanity url for: {guild}")
self.cog_unload()
await self.bot.unload_extension("robocop_ng.cogs.vanity_url")
@Cog.listener()
async def on_guild_update(self, before: Guild, after: Guild):

View File

@ -38,7 +38,6 @@ initial_cogs = [
"cogs.links",
"cogs.remind",
"cogs.robocronp",
"cogs.vanity_url",
"cogs.meme",
"cogs.invites",
"cogs.yubicootp",