Skip to content

Commit cbb4987

Browse files
committed
mdlink: Add option to send mobile-friendly link
When copying a message on mobile, you have to copy the entire message anyways, and then you have to remove the backticks. This option allows the link to be sent escaped instead of in backticks, i.e., \[foo](http:\/\/bar.com) instead of `[foo](http://bar.com)`
1 parent c448800 commit cbb4987

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

mdlink/mdlink.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
import typing as t
2+
13
from discord.ext import commands
4+
from discord.utils import escape_markdown
25

36
from bot import ModmailBot
47
from core import checks
@@ -14,10 +17,13 @@ def __init__(self, bot: ModmailBot):
1417
@commands.command()
1518
@checks.has_permissions(PermissionLevel.MODERATOR)
1619
@checks.thread_only()
17-
async def mdlink(self, ctx: commands.Context, *, text: str = "ModMail") -> None:
20+
async def mdlink(self, ctx: commands.Context, mobile: t.Optional[t.Literal["mobile", "m"]] = "", *, text: str = "ModMail") -> None:
1821
"""Return a link to the modmail thread in markdown syntax."""
1922
link = await self.bot.api.get_log_link(ctx.channel.id)
20-
await ctx.send(f"`[{text}]({link})`")
23+
if mobile:
24+
await ctx.send(escape_markdown(f"[{text}]({link})", as_needed=True, ignore_links=False))
25+
else:
26+
await ctx.send(f"`[{text}]({link})`")
2127

2228

2329
async def setup(bot: ModmailBot) -> None:

0 commit comments

Comments
 (0)