diff --git a/src/cogs/ffmeta.py b/src/cogs/ffmeta.py index 0d4a2c3..0469a3f 100644 --- a/src/cogs/ffmeta.py +++ b/src/cogs/ffmeta.py @@ -23,6 +23,8 @@ class FFMeta(commands.Cog): def jpegify_image(self, input_file: io.BytesIO, quality: int = 50, image_format: str = "jpeg") -> io.BytesIO: quality = min(1, max(quality, 100)) img_src = PIL.Image.open(input_file) + if image_format == "jpeg": + img_src = img_src.convert("RGB") img_dst = io.BytesIO() self.log.debug("Saving input file (%r) as %r with quality %r%%", input_file, image_format, quality) img_src.save(img_dst, format=image_format, quality=quality) diff --git a/src/cogs/gay_meter.py b/src/cogs/gay_meter.py new file mode 100644 index 0000000..96828f1 --- /dev/null +++ b/src/cogs/gay_meter.py @@ -0,0 +1,56 @@ +import asyncio +import random +import logging + +import discord +from discord.ext import commands + + +class MeterCog(commands.Cog): + def __init__(self, bot: commands.Bot): + self.bot = bot + self.log = logging.getLogger("jimmy.cogs.auto_responder") + self.cache = {} + + @commands.slash_command(name="gay-meter") + async def gay_meter(self, ctx: discord.ApplicationContext, user: discord.User = None): + """Checks how gay someone is""" + user = user or ctx.user + + await ctx.respond("Calculating...") + for i in range(0, 125, 25): + await ctx.edit(content="Calculating... %d%%" % i) + await asyncio.sleep(random.randint(1, 30) / 10) + + pct = user.id % 100 + await ctx.edit(content=f"{user.mention} is {pct}% gay.") + + @commands.slash_command(name="penis-length") + async def penis_meter(self, ctx: discord.ApplicationContext, user: discord.User = None): + """Checks the length of someone's penis.""" + user = user or ctx.user + n = self.cache.get(user) or random.randint(0, 100) + chunks = ["8"] + chunks += ["="] * n + chunks.append("B") + self.cache[user] = n + return await ctx.respond( + embed=discord.Embed( + title=f"{user.display_name}'s penis length:", + description="%d cm\n%s" % (n, "".join(chunks)) + ) + ) + + @commands.command() + @commands.is_owner() + async def clear_cache(self, ctx: commands.Context, user: discord.User = None): + """Clears the Meter cache""" + if not user: + self.cache = {} + else: + self.cache.pop(user, None) + return await ctx.message.add_reaction("\N{white heavy check mark}") + + +def setup(bot): + bot.add_cog(MeterCog(bot)) diff --git a/src/main.py b/src/main.py index 0f8b938..45b7cfe 100644 --- a/src/main.py +++ b/src/main.py @@ -211,6 +211,24 @@ async def delete_message(ctx: discord.ApplicationContext, message: discord.Messa await ctx.delete(delay=15) +@bot.slash_command(name="about") +async def about_me(self, ctx: discord.ApplicationContext): + embed = discord.Embed( + title="Jimmy v3", + description="A bot specifically for the LCC discord server(s).", + colour=discord.Colour.green() + ) + embed.add_field( + name="Source", + value="[Source code is available under AGPLv3.](https://git.i-am.nexus/nex/college-bot-v2)" + ) + user = await self.bot.fetch_user(421698654189912064) + appinfo = await self.bot.application_info() + author = appinfo.owner + embed.add_field(name="Author", value=f"{user.mention} created me. {author.mention} is running this instance.") + return await ctx.respond(embed=embed) + + @bot.check_once async def check_is_enabled(ctx: commands.Context | discord.ApplicationContext) -> bool: disabled = CONFIG["jimmy"].get("disabled_commands", [])