mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
[Mod] Remove tempban from data after unbanning (#2161)
Resolves #2160. Also resolves another issue where the bot will error out when getting the guild's invites when it doesn't have the Manage Server permission.
This commit is contained in:
parent
0870403299
commit
a9b328ff3c
@ -715,10 +715,13 @@ class Mod(commands.Cog):
|
|||||||
to send the newly unbanned user
|
to send the newly unbanned user
|
||||||
:returns: :class:`Invite`"""
|
:returns: :class:`Invite`"""
|
||||||
guild = ctx.guild
|
guild = ctx.guild
|
||||||
if "VANITY_URL" in guild.features and guild.me.permissions.manage_guild:
|
if guild.me.permissions.manage_guild:
|
||||||
|
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()
|
return await guild.vanity_invite()
|
||||||
invites = await guild.invites()
|
invites = await guild.invites()
|
||||||
|
else:
|
||||||
|
invites = []
|
||||||
for inv in invites: # Loop through the invites for the guild
|
for inv in invites: # Loop through the invites for the guild
|
||||||
if not (inv.max_uses or inv.max_age or inv.temporary):
|
if not (inv.max_uses or inv.max_age or inv.temporary):
|
||||||
# Invite is for the guild's default channel,
|
# Invite is for the guild's default channel,
|
||||||
@ -1393,7 +1396,7 @@ class Mod(commands.Cog):
|
|||||||
member = namedtuple("Member", "id guild")
|
member = namedtuple("Member", "id guild")
|
||||||
while self == self.bot.get_cog("Mod"):
|
while self == self.bot.get_cog("Mod"):
|
||||||
for guild in self.bot.guilds:
|
for guild in self.bot.guilds:
|
||||||
guild_tempbans = await self.settings.guild(guild).current_tempbans()
|
async with self.settings.guild(guild).current_tempbans() as guild_tempbans:
|
||||||
for uid in guild_tempbans:
|
for uid in guild_tempbans:
|
||||||
unban_time = datetime.utcfromtimestamp(
|
unban_time = datetime.utcfromtimestamp(
|
||||||
await self.settings.member(member(uid, guild)).banned_until()
|
await self.settings.member(member(uid, guild)).banned_until()
|
||||||
@ -1405,6 +1408,7 @@ class Mod(commands.Cog):
|
|||||||
self.unban_queue.append(queue_entry)
|
self.unban_queue.append(queue_entry)
|
||||||
try:
|
try:
|
||||||
await guild.unban(user, reason="Tempban finished")
|
await guild.unban(user, reason="Tempban finished")
|
||||||
|
guild_tempbans.remove(uid)
|
||||||
except discord.Forbidden:
|
except discord.Forbidden:
|
||||||
self.unban_queue.remove(queue_entry)
|
self.unban_queue.remove(queue_entry)
|
||||||
log.info("Failed to unban member due to permissions")
|
log.info("Failed to unban member due to permissions")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user