From 8b0d67202a0ebbfa17d53d56bef9e515574bdb66 Mon Sep 17 00:00:00 2001 From: Arjun Satarkar Date: Fri, 22 Mar 2024 17:19:46 -0400 Subject: teleport: add reason param --- teleport/teleport.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'teleport') diff --git a/teleport/teleport.py b/teleport/teleport.py index 2f4b5a6..a4c8100 100644 --- a/teleport/teleport.py +++ b/teleport/teleport.py @@ -1,6 +1,6 @@ import discord from redbot.core import commands - +import redbot.core class Teleport(commands.Cog): def __init__(self, bot): @@ -12,6 +12,8 @@ class Teleport(commands.Cog): self, ctx: commands.GuildContext, destination: discord.abc.GuildChannel | discord.Thread, + *, + reason: str | None ): if isinstance(destination, discord.Thread): parent = destination.parent @@ -29,20 +31,22 @@ class Teleport(commands.Cog): await ctx.react_quietly("❌") return - portal_to_template = "Portal opened to {dest}\n*(done by {user})*" + formatted_reason = redbot.core.utils.chat_formatting.italics(reason) if reason else "" + + portal_to_template = "Portal opened to {dest}" f" : {formatted_reason}\n*(done by {ctx.author.mention})*" source_message = await ctx.send( portal_to_template.format( - dest=destination.mention, user=ctx.author.mention + dest=destination.mention ), allowed_mentions=discord.AllowedMentions.none(), ) dest_message = await destination.send( - f"Portal opened from {source_message.jump_url}\n*(done by {ctx.author.mention})*", + f"Portal opened from {source_message.jump_url} : {formatted_reason}\n*(done by {ctx.author.mention})*", allowed_mentions=discord.AllowedMentions.none(), ) await source_message.edit( content=portal_to_template.format( - dest=dest_message.jump_url, user=ctx.author.mention + dest=dest_message.jump_url ), allowed_mentions=discord.AllowedMentions.none(), ) -- cgit v1.2.3-57-g22cb