Fix hackban
This commit is contained in:
parent
eebcfea2f5
commit
b78544a4fb
1 changed files with 12 additions and 10 deletions
22
cogs/mod.py
22
cogs/mod.py
|
@ -193,27 +193,29 @@ class ModCog:
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def hackban(self, ctx, target: int, *, reason: str = ""):
|
async def hackban(self, ctx, target: int, *, reason: str = ""):
|
||||||
"""Bans a user with their ID, doesn't message them, staff only."""
|
"""Bans a user with their ID, doesn't message them, staff only."""
|
||||||
target = ctx.guild.get_member(target)
|
target_user = self.bot.get_user(target)
|
||||||
|
target_member = ctx.guild.get_member(target)
|
||||||
# Hedge-proofing the code
|
# Hedge-proofing the code
|
||||||
if target == ctx.author:
|
if target == ctx.author.id:
|
||||||
return await ctx.send("You can't do mod actions on yourself.")
|
return await ctx.send("You can't do mod actions on yourself.")
|
||||||
elif self.check_if_target_is_staff(target):
|
elif target_member and self.check_if_target_is_staff(target_member):
|
||||||
return await ctx.send("I can't ban this user as "
|
return await ctx.send("I can't ban this user as "
|
||||||
"they're a member of staff.")
|
"they're a member of staff.")
|
||||||
|
|
||||||
safe_name = self.bot.escape_message(str(target))
|
safe_name = self.bot.escape_message(str(target_user))
|
||||||
|
|
||||||
await target.ban(reason=f"{ctx.author}, reason: {reason}",
|
await ctx.guild.ban(target_user,
|
||||||
delete_message_days=0)
|
reason=f"{ctx.author}, reason: {reason}",
|
||||||
|
delete_message_days=0)
|
||||||
chan_message = f"⛔ **Hackban**: {ctx.author.mention} banned "\
|
chan_message = f"⛔ **Hackban**: {ctx.author.mention} banned "\
|
||||||
f"{target.mention} | {safe_name}\n"\
|
f"{target_user.mention} | {safe_name}\n"\
|
||||||
f"🏷 __User ID__: {target.id}\n"
|
f"🏷 __User ID__: {target}\n"
|
||||||
if reason:
|
if reason:
|
||||||
chan_message += f"✏️ __Reason__: \"{reason}\""
|
chan_message += f"✏️ __Reason__: \"{reason}\""
|
||||||
else:
|
else:
|
||||||
chan_message += "Please add an explanation below. In the future"\
|
chan_message += "Please add an explanation below. In the future"\
|
||||||
", it is recommended to use `.ban <user> [reason]`"\
|
", it is recommended to use "\
|
||||||
" as the reason is automatically sent to the user."
|
"`.hackban <user> [reason]`."
|
||||||
|
|
||||||
log_channel = self.bot.get_channel(config.log_channel)
|
log_channel = self.bot.get_channel(config.log_channel)
|
||||||
await log_channel.send(chan_message)
|
await log_channel.send(chan_message)
|
||||||
|
|
Loading…
Reference in a new issue