From cdd8e23fbc3e32b2eba1060f866b2d601417c6c7 Mon Sep 17 00:00:00 2001 From: kzndotsh Date: Thu, 21 Nov 2024 21:46:47 -0500 Subject: [PATCH] docs(permafk.py): update permafk command description for clarity Clarify that the permafk status remains until the command is rerun. Add spacing for improved readability and maintainability of the code. --- tux/cogs/utility/permafk.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tux/cogs/utility/permafk.py b/tux/cogs/utility/permafk.py index 8818ac05..7ac0d9dd 100644 --- a/tux/cogs/utility/permafk.py +++ b/tux/cogs/utility/permafk.py @@ -23,7 +23,7 @@ async def remove_afk(self, target: int) -> None: @commands.guild_only() async def permafk(self, ctx: commands.Context[Tux], *, reason: str = "No reason.") -> discord.Message: """ - Set yourself permanently AFK so it doesnt remove your afk status if you send a message. + Set yourself permanently AFK until you rerun the command. Parameters ---------- @@ -32,16 +32,21 @@ async def permafk(self, ctx: commands.Context[Tux], *, reason: str = "No reason. reason : str, optional The reason you are AFK. """ + target = ctx.author + assert ctx.guild assert isinstance(target, discord.Member) + if await self.db.is_afk(target.id, guild_id=ctx.guild.id): await self.remove_afk(target.id) + return await ctx.send("Welcome back!") if len(target.display_name) >= CONST.NICKNAME_MAX_LENGTH - 6: truncated_name = f"{target.display_name[: CONST.NICKNAME_MAX_LENGTH - 9]}..." new_name = f"[AFK] {truncated_name}" + else: new_name = f"[AFK] {target.display_name}" @@ -50,6 +55,7 @@ async def permafk(self, ctx: commands.Context[Tux], *, reason: str = "No reason. with contextlib.suppress(discord.Forbidden): await target.edit(nick=new_name) + return await ctx.send( content="\N{SLEEPING SYMBOL} || You are now permanently afk! To remove afk run this command again. " + f"Reason: `{shortened_reason}`",