From 2993a3e13bf1eb939bf4ac451ffe19b64a30709a Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Tue, 23 Aug 2022 21:38:49 +0100 Subject: Support discord.py's new async cog loading --- bot/exts/fun/fun.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bot/exts/fun/fun.py') diff --git a/bot/exts/fun/fun.py b/bot/exts/fun/fun.py index e7337cb6..779db977 100644 --- a/bot/exts/fun/fun.py +++ b/bot/exts/fun/fun.py @@ -157,6 +157,6 @@ class Fun(Cog): await ctx.send(joke) -def setup(bot: Bot) -> None: +async def setup(bot: Bot) -> None: """Load the Fun cog.""" - bot.add_cog(Fun(bot)) + await bot.add_cog(Fun(bot)) -- cgit v1.2.3 From 9d87134225d9232c337583ead8860e22770bfede Mon Sep 17 00:00:00 2001 From: TizzySaurus <47674925+TizzySaurus@users.noreply.github.com> Date: Wed, 26 Oct 2022 23:13:25 +0100 Subject: Add ability to use replied message's content as `.randomcase` argument. (#1129) Co-authored-by: Xithrius <15021300+Xithrius@users.noreply.github.com> --- bot/exts/fun/fun.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'bot/exts/fun/fun.py') diff --git a/bot/exts/fun/fun.py b/bot/exts/fun/fun.py index 779db977..8056b033 100644 --- a/bot/exts/fun/fun.py +++ b/bot/exts/fun/fun.py @@ -6,9 +6,10 @@ from pathlib import Path from typing import Literal import pyjokes +from botcore.utils.commands import clean_text_or_reply from discord import Embed from discord.ext import commands -from discord.ext.commands import BadArgument, Cog, Context, clean_content +from discord.ext.commands import BadArgument, Cog, Context from bot.bot import Bot from bot.constants import Client, Colours, Emojis @@ -60,13 +61,14 @@ class Fun(Cog): raise BadArgument(f"`{Client.prefix}roll` only supports between 1 and 6 rolls.") @commands.command(name="randomcase", aliases=("rcase", "randomcaps", "rcaps",)) - async def randomcase_command(self, ctx: Context, *, text: clean_content(fix_channel_mentions=True)) -> None: - """Randomly converts the casing of a given `text`.""" + async def randomcase_command(self, ctx: Context, *, text: str | None) -> None: + """Randomly converts the casing of a given `text`, or the replied message.""" def conversion_func(text: str) -> str: """Randomly converts the casing of a given string.""" return "".join( char.upper() if round(random.random()) else char.lower() for char in text ) + text = await clean_text_or_reply(ctx, text) text, embed = await messages.get_text_and_embed(ctx, text) # Convert embed if it exists if embed is not None: -- cgit v1.2.3