mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-07 03:38:53 -05:00
[Mod] Added [p]hackban
This commit is contained in:
parent
e9e4fd083f
commit
2e5023be5f
45
cogs/mod.py
45
cogs/mod.py
@ -18,6 +18,7 @@ ACTIONS_REPR = {
|
|||||||
"CMUTE" : ("Channel mute", "\N{SPEAKER WITH CANCELLATION STROKE}"),
|
"CMUTE" : ("Channel mute", "\N{SPEAKER WITH CANCELLATION STROKE}"),
|
||||||
"SMUTE" : ("Server mute", "\N{SPEAKER WITH CANCELLATION STROKE}"),
|
"SMUTE" : ("Server mute", "\N{SPEAKER WITH CANCELLATION STROKE}"),
|
||||||
"SOFTBAN" : ("Softban", "\N{DASH SYMBOL} \N{HAMMER}"),
|
"SOFTBAN" : ("Softban", "\N{DASH SYMBOL} \N{HAMMER}"),
|
||||||
|
"HACKBAN" : ("Preemptive ban", "\N{BUST IN SILHOUETTE} \N{HAMMER}"),
|
||||||
"UNBAN" : ("Unban", "\N{DOVE OF PEACE}")
|
"UNBAN" : ("Unban", "\N{DOVE OF PEACE}")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,6 +28,7 @@ ACTIONS_CASES = {
|
|||||||
"CMUTE" : False,
|
"CMUTE" : False,
|
||||||
"SMUTE" : True,
|
"SMUTE" : True,
|
||||||
"SOFTBAN" : True,
|
"SOFTBAN" : True,
|
||||||
|
"HACKBAN" : True,
|
||||||
"UNBAN" : True
|
"UNBAN" : True
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -388,6 +390,49 @@ class Mod:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
|
@commands.command(no_pm=True, pass_context=True)
|
||||||
|
@checks.admin_or_permissions(ban_members=True)
|
||||||
|
async def hackban(self, ctx, user_id: int, *, reason: str = None):
|
||||||
|
"""Preemptively bans user from the server
|
||||||
|
|
||||||
|
A user ID needs to be provided
|
||||||
|
If the user is present in the server a normal ban will be
|
||||||
|
issued instead"""
|
||||||
|
user_id = str(user_id)
|
||||||
|
author = ctx.message.author
|
||||||
|
server = author.server
|
||||||
|
|
||||||
|
ban_list = await self.bot.get_bans(server)
|
||||||
|
is_banned = discord.utils.get(ban_list, id=user_id)
|
||||||
|
|
||||||
|
if is_banned:
|
||||||
|
await self.bot.say("User is already banned.")
|
||||||
|
return
|
||||||
|
|
||||||
|
user = server.get_member(user_id)
|
||||||
|
if user is not None:
|
||||||
|
await ctx.invoke(self.ban, user=user, reason=reason)
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
await self.bot.http.ban(user_id, server.id)
|
||||||
|
except discord.NotFound:
|
||||||
|
await self.bot.say("User not found. Have you provided the "
|
||||||
|
"correct user ID?")
|
||||||
|
except discord.Forbidden:
|
||||||
|
await self.bot.say("I lack the permissions to do this.")
|
||||||
|
else:
|
||||||
|
logger.info("{}({}) hackbanned {}"
|
||||||
|
"".format(author.name, author.id, user_id))
|
||||||
|
user = await self.bot.get_user_info(user_id)
|
||||||
|
await self.new_case(server,
|
||||||
|
action="HACKBAN",
|
||||||
|
mod=author,
|
||||||
|
user=user,
|
||||||
|
reason=reason)
|
||||||
|
await self.bot.say("Done. The user will not be able to join this "
|
||||||
|
"server.")
|
||||||
|
|
||||||
@commands.command(no_pm=True, pass_context=True)
|
@commands.command(no_pm=True, pass_context=True)
|
||||||
@checks.admin_or_permissions(ban_members=True)
|
@checks.admin_or_permissions(ban_members=True)
|
||||||
async def softban(self, ctx, user: discord.Member, *, reason: str = None):
|
async def softban(self, ctx, user: discord.Member, *, reason: str = None):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user