mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-08 10:22:31 -05:00
(cherry picked from commit d932abad16)
Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
@@ -172,8 +172,11 @@ class KickBanMixin(MixinMeta):
|
|||||||
else:
|
else:
|
||||||
tempbans = await self.config.guild(guild).current_tempbans()
|
tempbans = await self.config.guild(guild).current_tempbans()
|
||||||
|
|
||||||
ban_list = [ban.user.id for ban in await guild.bans()]
|
try:
|
||||||
if user.id in ban_list:
|
await guild.fetch_ban(user)
|
||||||
|
except discord.NotFound:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
if user.id in tempbans:
|
if user.id in tempbans:
|
||||||
async with self.config.guild(guild).current_tempbans() as tempbans:
|
async with self.config.guild(guild).current_tempbans() as tempbans:
|
||||||
tempbans.remove(user.id)
|
tempbans.remove(user.id)
|
||||||
@@ -474,13 +477,14 @@ class KickBanMixin(MixinMeta):
|
|||||||
|
|
||||||
tempbans = await self.config.guild(guild).current_tempbans()
|
tempbans = await self.config.guild(guild).current_tempbans()
|
||||||
|
|
||||||
ban_list = await guild.bans()
|
|
||||||
for entry in ban_list:
|
|
||||||
for user_id in user_ids:
|
for user_id in user_ids:
|
||||||
if entry.user.id == user_id:
|
|
||||||
if user_id in tempbans:
|
if user_id in tempbans:
|
||||||
# We need to check if a user is tempbanned here because otherwise they won't be processed later on.
|
# We need to check if a user is tempbanned here because otherwise they won't be processed later on.
|
||||||
continue
|
continue
|
||||||
|
try:
|
||||||
|
await guild.fetch_ban(discord.Object(user_id))
|
||||||
|
except discord.NotFound:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
errors[user_id] = _("User with ID {user_id} is already banned.").format(
|
errors[user_id] = _("User with ID {user_id} is already banned.").format(
|
||||||
user_id=user_id
|
user_id=user_id
|
||||||
@@ -907,14 +911,13 @@ class KickBanMixin(MixinMeta):
|
|||||||
guild = ctx.guild
|
guild = ctx.guild
|
||||||
author = ctx.author
|
author = ctx.author
|
||||||
audit_reason = get_audit_reason(ctx.author, reason, shorten=True)
|
audit_reason = get_audit_reason(ctx.author, reason, shorten=True)
|
||||||
bans = await guild.bans()
|
try:
|
||||||
bans = [be.user for be in bans]
|
ban_entry = await guild.fetch_ban(discord.Object(user_id))
|
||||||
user = discord.utils.get(bans, id=user_id)
|
except discord.NotFound:
|
||||||
if not user:
|
|
||||||
await ctx.send(_("It seems that user isn't banned!"))
|
await ctx.send(_("It seems that user isn't banned!"))
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
await guild.unban(user, reason=audit_reason)
|
await guild.unban(ban_entry.user, reason=audit_reason)
|
||||||
except discord.HTTPException:
|
except discord.HTTPException:
|
||||||
await ctx.send(_("Something went wrong while attempting to unban that user."))
|
await ctx.send(_("Something went wrong while attempting to unban that user."))
|
||||||
return
|
return
|
||||||
@@ -924,7 +927,7 @@ class KickBanMixin(MixinMeta):
|
|||||||
guild,
|
guild,
|
||||||
ctx.message.created_at.replace(tzinfo=timezone.utc),
|
ctx.message.created_at.replace(tzinfo=timezone.utc),
|
||||||
"unban",
|
"unban",
|
||||||
user,
|
ban_entry.user,
|
||||||
author,
|
author,
|
||||||
reason,
|
reason,
|
||||||
until=None,
|
until=None,
|
||||||
|
|||||||
Reference in New Issue
Block a user