From ca9c4e063d1a916004030a241a143ca837bc4b1f Mon Sep 17 00:00:00 2001 From: Ave Ozkal Date: Sun, 23 Dec 2018 18:44:16 +0300 Subject: [PATCH] ban/kick: fix them, and add silentban --- README.md | 1 + cogs/mod.py | 39 +++++++++++++++++++++++++++++++++------ config.py.template | 2 ++ 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index bfcde95..dd5670e 100755 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ Based on https://gitlab.com/ao/dpybotbase - [ ] Logging: bans - [ ] Logging: kicks - [x] Moderation: ban +- [x] Moderation: silentban - [x] Moderation: kick - [x] Moderation: userinfo - [ ] Moderation: approve-revoke (community) diff --git a/cogs/mod.py b/cogs/mod.py index f7a32e9..1279851 100644 --- a/cogs/mod.py +++ b/cogs/mod.py @@ -3,10 +3,9 @@ from discord.ext import commands import config -class AdminCog: +class ModCog: def __init__(self, bot): self.bot = bot - self.modlog_channel = bot.get_channel(config.modlog_channel) def check_if_staff(ctx): return any(r.id in config.staff_role_ids for r in ctx.author.roles) @@ -49,7 +48,8 @@ class AdminCog: ", it is recommended to use `.ban [reason]`"\ " as the reason is automatically sent to the user." - await self.modlog_channel.send(chan_message) + modlog_channel = self.bot.get_channel(config.modlog_channel) + await modlog_channel.send(chan_message) @commands.bot_has_permissions(ban_members=True) @commands.check(check_if_staff) @@ -76,7 +76,7 @@ class AdminCog: await target.ban(reason=f"{ctx.author}, reason: {reason}", delete_message_days=0) - chan_message = f"👢 **Ban**: {ctx.author.mention} banned "\ + chan_message = f"⛔ **Ban**: {ctx.author.mention} banned "\ f"{target.mention} | {safe_name}\n"\ f"🏷 __User ID__: {target.id}\n" if reason: @@ -86,9 +86,36 @@ class AdminCog: ", it is recommended to use `.ban [reason]`"\ " as the reason is automatically sent to the user." - await self.modlog_channel.send(chan_message) + modlog_channel = self.bot.get_channel(config.modlog_channel) + await modlog_channel.send(chan_message) await ctx.send(f"{safe_name} is now b&. 👍") + @commands.bot_has_permissions(ban_members=True) + @commands.check(check_if_staff) + @commands.command() + async def silentban(self, ctx, target: discord.Member, *, reason: str = ""): + """Bans a user, staff only.""" + if self.check_if_target_is_staff(target): + return await ctx.send("I can't ban this user as " + "they're a member of staff.") + + safe_name = self.bot.escape_message(str(target)) + + await target.ban(reason=f"{ctx.author}, reason: {reason}", + delete_message_days=0) + chan_message = f"⛔ **Silent ban**: {ctx.author.mention} banned "\ + f"{target.mention} | {safe_name}\n"\ + f"🏷 __User ID__: {target.id}\n" + if reason: + chan_message += f"✏️ __Reason__: \"{reason}\"" + else: + chan_message += "Please add an explanation below. In the future"\ + ", it is recommended to use `.ban [reason]`"\ + " as the reason is automatically sent to the user." + + modlog_channel = self.bot.get_channel(config.modlog_channel) + await modlog_channel.send(chan_message) + @commands.check(check_if_staff) @commands.command() async def userinfo(self, ctx, *, user: discord.Member): @@ -109,4 +136,4 @@ class AdminCog: def setup(bot): - bot.add_cog(AdminCog(bot)) + bot.add_cog(ModCog(bot)) diff --git a/config.py.template b/config.py.template index 456cfee..2d4239b 100644 --- a/config.py.template +++ b/config.py.template @@ -15,3 +15,5 @@ staff_role_ids = [526384077679624192, # Team role in NotSwitched 526372582455508992, # Mod role in NotSwitched 526372554081042462, # Bot management role in NotSwitched 526383985430102016] # Wizard role in NotSwitched + +modlog_channel = 526377735908491284 # Log channel in NotSwitched discord