mirror of
https://github.com/Ryujinx/ryuko-ng.git
synced 2024-12-23 01:35:30 +00:00
Add massban command
This commit is contained in:
parent
6a6c88cdb8
commit
1ebb049f09
42
cogs/mod.py
42
cogs/mod.py
|
@ -286,6 +286,48 @@ class Mod(Cog):
|
||||||
await log_channel.send(chan_message)
|
await log_channel.send(chan_message)
|
||||||
await ctx.send(f"{safe_name} is now b&. 👍")
|
await ctx.send(f"{safe_name} is now b&. 👍")
|
||||||
|
|
||||||
|
@commands.guild_only()
|
||||||
|
@commands.bot_has_permissions(ban_members=True)
|
||||||
|
@commands.check(check_if_staff)
|
||||||
|
@commands.command()
|
||||||
|
async def massban(self, ctx, targets: str):
|
||||||
|
"""Bans users with their IDs, doesn't message them, staff only."""
|
||||||
|
for target_str in targets.split(" "):
|
||||||
|
target = int(target_str)
|
||||||
|
target_user = await self.bot.fetch_user(target)
|
||||||
|
target_member = ctx.guild.get_member(target)
|
||||||
|
# Hedge-proofing the code
|
||||||
|
if target == ctx.author.id:
|
||||||
|
return await ctx.send("You can't do mod actions on yourself.")
|
||||||
|
elif target == self.bot.user:
|
||||||
|
return await ctx.send(
|
||||||
|
f"I'm sorry {ctx.author.mention}, I'm afraid I can't do that."
|
||||||
|
)
|
||||||
|
elif target_member and self.check_if_target_is_staff(target_member):
|
||||||
|
return await ctx.send("I can't ban this user as they're a member of staff.")
|
||||||
|
|
||||||
|
userlog(target, ctx.author, f"massban", "bans", target_user.name)
|
||||||
|
|
||||||
|
safe_name = await commands.clean_content(escape_markdown=True).convert(
|
||||||
|
ctx, str(target)
|
||||||
|
)
|
||||||
|
|
||||||
|
await ctx.guild.ban(
|
||||||
|
target_user, reason=f"{ctx.author}, reason: massban", delete_message_days=0
|
||||||
|
)
|
||||||
|
chan_message = (
|
||||||
|
f"⛔ **Hackban**: {str(ctx.author)} banned "
|
||||||
|
f"{target_user.mention} | {safe_name}\n"
|
||||||
|
f"🏷 __User ID__: {target}\n"
|
||||||
|
"Please add an explanation below."
|
||||||
|
)
|
||||||
|
|
||||||
|
chan_message += f"\n🔗 __Jump__: <{ctx.message.jump_url}>"
|
||||||
|
|
||||||
|
log_channel = self.bot.get_channel(config.modlog_channel)
|
||||||
|
await log_channel.send(chan_message)
|
||||||
|
await ctx.send(f"All {len(targets)} users are now b&. 👍")
|
||||||
|
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
@commands.bot_has_permissions(ban_members=True)
|
@commands.bot_has_permissions(ban_members=True)
|
||||||
@commands.check(check_if_staff)
|
@commands.check(check_if_staff)
|
||||||
|
|
Loading…
Reference in a new issue