vanity_url: Fix crash when editing a guild (#96)
This commit is contained in:
parent
7c4a57d289
commit
b2cda3fe85
2 changed files with 9 additions and 4 deletions
|
@ -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:
|
||||
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):
|
||||
|
|
|
@ -38,7 +38,6 @@ initial_cogs = [
|
|||
"cogs.links",
|
||||
"cogs.remind",
|
||||
"cogs.robocronp",
|
||||
"cogs.vanity_url",
|
||||
"cogs.meme",
|
||||
"cogs.invites",
|
||||
"cogs.yubicootp",
|
||||
|
|
Loading…
Reference in a new issue