From 41836073727070fa4fae0b7f8c69159a577c8513 Mon Sep 17 00:00:00 2001 From: bobloy Date: Thu, 15 Jul 2021 16:05:39 -0400 Subject: [PATCH] Add option for skipping bots --- timerole/timerole.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/timerole/timerole.py b/timerole/timerole.py index f0eb716..14a0bb4 100644 --- a/timerole/timerole.py +++ b/timerole/timerole.py @@ -37,7 +37,7 @@ class Timerole(Cog): self.bot = bot self.config = Config.get_conf(self, identifier=9811198108111121, force_registration=True) default_global = {} - default_guild = {"announce": None, "reapply": True, "roles": {}} + default_guild = {"announce": None, "reapply": True, "roles": {}, "skipbots": True} default_rolemember = {"had_role": False, "check_again_time": None} self.config.register_global(**default_global) @@ -154,6 +154,14 @@ class Timerole(Cog): await self.config.guild(guild).reapply.set(not current_setting) await ctx.maybe_send_embed(f"Reapplying roles is now set to: {not current_setting}") + @timerole.command() + async def skipbots(self, ctx: commands.Context): + """Toggle skipping bots when adding/removing roles. Defaults to True""" + guild = ctx.guild + current_setting = await self.config.guild(guild).skipbots() + await self.config.guild(guild).skipbots.set(not current_setting) + await ctx.maybe_send_embed(f"Skipping bots is now set to: {not current_setting}") + @timerole.command() async def delrole(self, ctx: commands.Context, role: discord.Role): """Deletes a role from being added/removed after specified time""" @@ -202,6 +210,7 @@ class Timerole(Cog): remove_results = "" reapply = all_guilds[guild_id]["reapply"] role_dict = all_guilds[guild_id]["roles"] + skipbots = all_guilds[guild_id]["skipbots"] if not any(role_dict.values()): # No roles log.debug(f"No roles are configured for guild: {guild}") @@ -211,6 +220,10 @@ class Timerole(Cog): # log.debug(f"{all_mr=}") async for member in AsyncIter(guild.members, steps=10): + + if member.bot and skipbots: + continue + addlist = [] removelist = []