diff --git a/README.md b/README.md index e693327..7b5f3f8 100755 --- a/README.md +++ b/README.md @@ -24,7 +24,8 @@ Based on https://gitlab.com/ao/dpybotbase - [x] Moderation: kick - [x] Moderation: userinfo - [x] Moderation: approve-revoke (community) -- [ ] Moderation: addhacker-removehacker +- [x] Moderation: addhacker-removehacker (hacker) +- [x] Moderation: probate-unprobate (participant) - [ ] Moderation: lock-soft-unlock (channel lockdown) - [ ] Moderation: timelock (channel lockdown with time) - [ ] Moderation: mute-unmute @@ -33,7 +34,6 @@ Based on https://gitlab.com/ao/dpybotbase - [x] Moderation: botnickname - [x] Moderation: nickname - [ ] Moderation: clear/purge -- [ ] Moderation: probate-unprobate - [ ] Moderation: watch-unwatch (using log module from akbbot) - [ ] Warns: warn - [ ] Warns: delwarnid-delwarn diff --git a/Robocop.py b/Robocop.py index 301b864..3d0ea84 100755 --- a/Robocop.py +++ b/Robocop.py @@ -40,8 +40,10 @@ def get_prefix(bot, message): initial_extensions = ['cogs.common', 'cogs.admin', 'cogs.basic', - "cogs.err", - "cogs.verification", + 'cogs.err', + 'cogs.verification', + 'cogs.logs', + 'cogs.legacy', 'cogs.links', 'cogs.mod', 'cogs.meme'] diff --git a/cogs/legacy.py b/cogs/legacy.py new file mode 100644 index 0000000..d047dd0 --- /dev/null +++ b/cogs/legacy.py @@ -0,0 +1,22 @@ +from discord.ext import commands + + +class Legacy: + def __init__(self, bot): + self.bot = bot + + @commands.command(hidden=True, aliases=["removehacker"]) + async def probate(self, ctx): + """Use .revoke """ + await ctx.send("This command was replaced with `.revoke `" + " on Robocop-NG, please use that instead.") + + @commands.command(hidden=True, aliases=["addhacker"]) + async def unprobate(self, ctx): + """Use .approve """ + await ctx.send("This command was replaced with `.approve `" + " on Robocop-NG, please use that instead.") + + +def setup(bot): + bot.add_cog(Legacy(bot)) diff --git a/cogs/lockdown.py b/cogs/lockdown.py index 8c4d143..15311fd 100644 --- a/cogs/lockdown.py +++ b/cogs/lockdown.py @@ -1,7 +1,7 @@ import discord import asyncio from discord.ext import commands -from config import log_channel, staff_role_ids, participant_role, community_channels, general_channels, hacker_role, community_role +from config import log_channel, staff_role_ids, named_roles, community_channels, general_channels class Lockdown: @@ -16,9 +16,9 @@ class Lockdown: """Locks the channel""" log_chan = self.bot.get_channel(log_channel) if ctx.message.channel in community_channels: - roles = (hacker_role, community_role) + roles = (named_roles["hacker"], named_roles["community"]) else: - roles = participant_role + roles = named_roles["participant"] overwrites = ctx.message.channel.overwrites_for(roles[0]) if not overwrites.send_message: await ctx.send("This channel is already locked!") diff --git a/cogs/mod.py b/cogs/mod.py index 03143fc..ceb3b36 100644 --- a/cogs/mod.py +++ b/cogs/mod.py @@ -141,38 +141,46 @@ class ModCog: @commands.guild_only() @commands.check(check_if_staff) @commands.command() - async def approve(self, ctx): - approval_list = ctx.message.mentions - community_role = ctx.guild.get_role(config.community_role) - for to_approve in approval_list: - await to_approve.add_roles(community_role, - reason=str(ctx.author)) + async def approve(self, ctx, target: discord.Member, + role: str = "community"): + if role not in config.named_roles: + return await ctx.send("No such role! Available roles: " + + ','.join(config.named_roles)) - await ctx.send(f"Approved {len(approval_list)} member(s).") log_channel = self.bot.get_channel(config.log_channel) + target_role = ctx.guild.get_role(config.named_roles[role]) - approved_mentions = [approved.mention for approved in approval_list] - await log_channel.send(f"✅ Approved: {ctx.author.mention} approved" - f" {len(approval_list)} members\n" - f"{' '.join(approved_mentions)}") # HACK + if target_role in target.roles: + return await ctx.send("Target already has this role.") + + await target.add_roles(target_role, reason=str(ctx.author)) + + await ctx.send(f"Approved {target.mention} to role {role}.") + + await log_channel.send(f"✅ Approved: {ctx.author.mention} added" + f" {role} to {target.mention}") @commands.guild_only() @commands.check(check_if_staff) @commands.command(aliases=["unapprove"]) - async def revoke(self, ctx): - revoke_list = ctx.message.mentions - community_role = ctx.guild.get_role(config.community_role) - for to_revoke in revoke_list: - await to_revoke.remove_roles(community_role, - reason=str(ctx.author)) + async def revoke(self, ctx, target: discord.Member, + role: str = "community"): + if role not in config.named_roles: + return await ctx.send("No such role! Available roles: " + + ','.join(config.named_roles)) - await ctx.send(f"Un-approved {len(revoke_list)} member(s).") log_channel = self.bot.get_channel(config.log_channel) + target_role = ctx.guild.get_role(config.named_roles[role]) - revoked_mentions = [revoked.mention for revoked in revoke_list] - await log_channel.send(f"❌ Un-approved: {ctx.author.mention} approved" - f" {len(revoke_list)} members\n" - f"{' '.join(revoked_mentions)}") # HACK + if target_role not in target.roles: + return await ctx.send("Target doesn't have this role.") + + await target.remove_roles(target_role, reason=str(ctx.author)) + + await ctx.send(f"Un-approved {target.mention} from role {role}.") + + await log_channel.send(f"❌ Un-approved: {ctx.author.mention} removed" + f" {role} from {target.mention}") @commands.guild_only() @commands.check(check_if_staff) diff --git a/config.py.template b/config.py.template index b8f2a6b..73ab340 100644 --- a/config.py.template +++ b/config.py.template @@ -22,6 +22,14 @@ guild_whitelist = [ 269333940928512010 # ReSwitched discord ] +# Named roles to be used with .approve and .revoke +# The defaults are for NotSwitched +named_roles = { + "community": 526378381839695872, + "hacker": 526471781184176139, + "participant": 526378358129557506 +} + bot_manager_role_id = 526372554081042462 # Bot management role in NotSwitched staff_role_ids = [526384077679624192, # Team role in NotSwitched 526372582455508992, # Mod role in NotSwitched @@ -30,9 +38,6 @@ staff_role_ids = [526384077679624192, # Team role in NotSwitched log_channel = 526377735908491284 # Log channel in NotSwitched welcome_channel = 526372470752673792 # rules-info channel in NotSwitched -participant_role = 526378358129557506 # participant role in NotSwitched -community_role = 526378381839695872 # community role in NotSwitched -hacker_role = 526471781184176139 # hacker role in NotSwitched community_channels = [526378423468425236] # Channels requiring community role general_channels = [526372255052201995] # Channels everyone can access