[Mod] Make tempban not fail if no vanity url is set up (#4714)

* catch if a vanity url is not set up

* black

Co-authored-by: David Bauch <david.bauch@capgemini.com>
This commit is contained in:
Dav 2021-01-17 23:42:00 +01:00 committed by GitHub
parent 2b5d72c7a4
commit d7a3da49f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,7 +39,14 @@ class KickBanMixin(MixinMeta):
if my_perms.manage_guild or my_perms.administrator: if my_perms.manage_guild or my_perms.administrator:
if "VANITY_URL" in guild.features: if "VANITY_URL" in guild.features:
# guild has a vanity url so use it as the one to send # guild has a vanity url so use it as the one to send
return await guild.vanity_invite() try:
return await guild.vanity_invite()
except discord.NotFound:
# If a guild has the vanity url feature,
# but does not have it set up,
# this prevents the command from failing
# and defaults back to another regular invite.
pass
invites = await guild.invites() invites = await guild.invites()
else: else:
invites = [] invites = []