ban/kick: fix them, and add silentban
This commit is contained in:
parent
0c9352fe33
commit
ca9c4e063d
3 changed files with 36 additions and 6 deletions
|
@ -20,6 +20,7 @@ Based on https://gitlab.com/ao/dpybotbase
|
||||||
- [ ] Logging: bans
|
- [ ] Logging: bans
|
||||||
- [ ] Logging: kicks
|
- [ ] Logging: kicks
|
||||||
- [x] Moderation: ban
|
- [x] Moderation: ban
|
||||||
|
- [x] Moderation: silentban
|
||||||
- [x] Moderation: kick
|
- [x] Moderation: kick
|
||||||
- [x] Moderation: userinfo
|
- [x] Moderation: userinfo
|
||||||
- [ ] Moderation: approve-revoke (community)
|
- [ ] Moderation: approve-revoke (community)
|
||||||
|
|
39
cogs/mod.py
39
cogs/mod.py
|
@ -3,10 +3,9 @@ from discord.ext import commands
|
||||||
import config
|
import config
|
||||||
|
|
||||||
|
|
||||||
class AdminCog:
|
class ModCog:
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.modlog_channel = bot.get_channel(config.modlog_channel)
|
|
||||||
|
|
||||||
def check_if_staff(ctx):
|
def check_if_staff(ctx):
|
||||||
return any(r.id in config.staff_role_ids for r in ctx.author.roles)
|
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 <user> [reason]`"\
|
", it is recommended to use `.ban <user> [reason]`"\
|
||||||
" as the reason is automatically sent to the user."
|
" 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.bot_has_permissions(ban_members=True)
|
||||||
@commands.check(check_if_staff)
|
@commands.check(check_if_staff)
|
||||||
|
@ -76,7 +76,7 @@ class AdminCog:
|
||||||
|
|
||||||
await target.ban(reason=f"{ctx.author}, reason: {reason}",
|
await target.ban(reason=f"{ctx.author}, reason: {reason}",
|
||||||
delete_message_days=0)
|
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"{target.mention} | {safe_name}\n"\
|
||||||
f"🏷 __User ID__: {target.id}\n"
|
f"🏷 __User ID__: {target.id}\n"
|
||||||
if reason:
|
if reason:
|
||||||
|
@ -86,9 +86,36 @@ class AdminCog:
|
||||||
", it is recommended to use `.ban <user> [reason]`"\
|
", it is recommended to use `.ban <user> [reason]`"\
|
||||||
" as the reason is automatically sent to the user."
|
" 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&. 👍")
|
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 <user> [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.check(check_if_staff)
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def userinfo(self, ctx, *, user: discord.Member):
|
async def userinfo(self, ctx, *, user: discord.Member):
|
||||||
|
@ -109,4 +136,4 @@ class AdminCog:
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
bot.add_cog(AdminCog(bot))
|
bot.add_cog(ModCog(bot))
|
||||||
|
|
|
@ -15,3 +15,5 @@ staff_role_ids = [526384077679624192, # Team role in NotSwitched
|
||||||
526372582455508992, # Mod role in NotSwitched
|
526372582455508992, # Mod role in NotSwitched
|
||||||
526372554081042462, # Bot management role in NotSwitched
|
526372554081042462, # Bot management role in NotSwitched
|
||||||
526383985430102016] # Wizard role in NotSwitched
|
526383985430102016] # Wizard role in NotSwitched
|
||||||
|
|
||||||
|
modlog_channel = 526377735908491284 # Log channel in NotSwitched discord
|
||||||
|
|
Loading…
Reference in a new issue