aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArjun Satarkar <me@arjunsatarkar.net>2024-03-22 21:19:46 +0000
committerArjun Satarkar <me@arjunsatarkar.net>2024-03-22 21:19:46 +0000
commit8b0d67202a0ebbfa17d53d56bef9e515574bdb66 (patch)
tree8113a9ab057baa9f5b1277aa335202bc0df6753c
parente64373979384c82580d7b8db582d48897096b992 (diff)
downloadaps-cogs-8b0d67202a0ebbfa17d53d56bef9e515574bdb66.tar
aps-cogs-8b0d67202a0ebbfa17d53d56bef9e515574bdb66.tar.gz
aps-cogs-8b0d67202a0ebbfa17d53d56bef9e515574bdb66.zip
teleport: add reason param
-rw-r--r--teleport/teleport.py14
1 files changed, 9 insertions, 5 deletions
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(),
)