diff --git a/penis/__init__.py b/penis/__init__.py index 3c6cc7cf..0a95c56e 100644 --- a/penis/__init__.py +++ b/penis/__init__.py @@ -4,4 +4,4 @@ async def setup(bot: Red): - await bot.add_cog(Penis()) + await bot.add_cog(Penis(bot)) diff --git a/penis/penis.py b/penis/penis.py index a5032d2f..7f50d1d3 100644 --- a/penis/penis.py +++ b/penis/penis.py @@ -1,7 +1,7 @@ import random import discord -from redbot.core import commands +from redbot.core import Config, commands from redbot.core.utils.chat_formatting import pagify DONG_DISTRIBUTION_CONST = 30 @@ -12,37 +12,101 @@ class Penis(commands.Cog): """Penis related commands.""" - def __init__(self): - pass + def __init__(self, bot): + self.bot = bot + self.config = Config.get_conf( + self, + identifier=928374651, + force_registration=True + ) + self.config.register_guild(mod_behaviour=False) @commands.command() + @commands.guild_only() async def penis(self, ctx, *users: discord.Member): - """Detects user's penis length + """Detects user's penis length. This is 100% accurate. - Enter multiple users for an accurate comparison!""" + Enter multiple users for an accurate comparison! + """ dongs = {} msg = "" - state = random.getstate() - if len(users) == 0: + if not users: users = (ctx.author,) + mod_behaviour = await self.config.guild(ctx.guild).mod_behaviour() + for user in users: - random.seed(user.id) - dongs[user] = "8{}D".format("=" * random.randint(0, DONG_DISTRIBUTION_CONST)) + is_mod = mod_behaviour and ( + user.id == ctx.guild.owner_id + or await self.bot.is_mod(user) + ) + + if is_mod: + dongs[user] = ("8=D", True) + else: + rng = random.Random(user.id) + dong = "8{}D".format( + "=" * rng.randint(0, DONG_DISTRIBUTION_CONST) + ) + dongs[user] = (dong, False) - random.setstate(state) - dongs = sorted(dongs.items(), key=lambda x: x[1]) + dongs = sorted( + dongs.items(), + key=lambda x: x[1][0] + ) - for user, dong in dongs: - if len(dong) <= SMALL_DONG_CONST: - msg += "**{}'s size:**\n{}\nlol small\n".format(user.display_name, dong) + for user, (dong, is_mod) in dongs: + if is_mod: + msg += ( + f"**{user.display_name}'s size:**\n" + f"{dong}\n" + "woah, now that's NOT a dong!\n" + ) + elif len(dong) <= SMALL_DONG_CONST: + msg += ( + f"**{user.display_name}'s size:**\n" + f"{dong}\n" + "lol small\n" + ) elif len(dong) <= BIG_DONG_CONST: - msg += "**{}'s size:**\n{}\n".format(user.display_name, dong) + msg += ( + f"**{user.display_name}'s size:**\n" + f"{dong}\n" + ) else: - msg += "**{}'s size:**\n{}\nwow, now that's a dong!\n".format(user.display_name, dong) + msg += ( + f"**{user.display_name}'s size:**\n" + f"{dong}\n" + "wow, now that's a dong!\n" + ) for page in pagify(msg): await ctx.send(page) + + @commands.command() + @commands.guild_only() + @commands.admin_or_permissions(manage_guild=True) + async def penis_state(self, ctx) : + """Toggle moderator behaviour.""" + + config = self.config.guild(ctx.guild) + current = await config.mod_behaviour() + new_value = not current + + await config.mod_behaviour.set(new_value) + + if new_value: + status = "enabled" + else: + status = "disabled" + + await ctx.send( + f"The truth has been **{status}**." + ) + + +async def setup(bot): + await bot.add_cog(Penis(bot))