Skip to content

Commit d4f13da

Browse files
committed
add back bad deletions
we use this to forward message references
1 parent 33efae0 commit d4f13da

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

modules/manuals.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
import constants
3232
import core
33-
33+
from core.utils.paginator import TextPager
3434

3535
class LibEnum(Enum):
3636
wavelink = ("https://wavelink.readthedocs.io/en/latest", constants.Colours.PYTHONISTA_BG, "wavelink")
@@ -94,6 +94,19 @@ def _smart_guess_lib(self, ctx: core.Context) -> LibEnum | None:
9494
return LibEnum.twitchio
9595

9696
return None
97+
98+
async def context_reply(
99+
self,
100+
ctx: core.Context,
101+
content: str | None = discord.utils.MISSING,
102+
embed: discord.Embed | None = discord.utils.MISSING,
103+
reference: discord.MessageReference | None = None,
104+
mention_author: bool = True
105+
) -> discord.Message:
106+
if ctx.message.reference and not reference:
107+
reference = ctx.message.reference
108+
109+
return await ctx.send(content=content, embed=embed, reference=reference, mention_author=mention_author)
97110

98111
@commands.command(
99112
"rtfm",
@@ -127,7 +140,7 @@ async def rtfm(self, ctx: core.Context, *, query: str) -> None:
127140
await ctx.reply("Sorry, I couldn't apply a default library to this channel. Try again with a library?")
128141
return
129142

130-
await ctx.reply(str(lib.value))
143+
await self.context_reply(ctx, str(lib.value))
131144
return
132145

133146
labels = False
@@ -160,7 +173,7 @@ async def rtfm(self, ctx: core.Context, *, query: str) -> None:
160173
return
161174

162175
if not final_query:
163-
await ctx.reply(str(lib.value[0]))
176+
await self.context_reply(ctx, str(lib.value[0]))
164177
return
165178

166179
url = self.target.with_path("/api/public/rtfm.sphinx").with_query(
@@ -225,7 +238,7 @@ async def rtfs(self, ctx: core.Context, *, query: str) -> None:
225238
await ctx.reply("Sorry, I couldn't apply a default library to this channel. Try again with a library?")
226239
return
227240

228-
await ctx.reply(str(lib.value))
241+
await self.context_reply(ctx, str(lib.value))
229242
return
230243

231244
source = False
@@ -279,13 +292,13 @@ async def rtfs(self, ctx: core.Context, *, query: str) -> None:
279292
await ctx.send("Could not find anything. Sorry.")
280293
return
281294

282-
nodes = matches["nodes"]
295+
nodes: dict[str, str] = matches["nodes"]
283296

284297
if not source:
285298
out = [f"[{name}]({url})" for name, url in nodes.items()]
286299

287300
author: str = f"query Time: {float(matches['query_time']):.03f} • commit {matches['commit'][:6]}"
288-
footer: str = f"Is the api behind on commits? Use {discord.utils.escape_mentions(ctx.prefix)}rtfs-reload"
301+
footer: str = f"Is the api behind on commits? Use {discord.utils.escape_mentions(ctx.prefix)}rtfs-reload" # type: ignore
289302

290303
embed: discord.Embed = discord.Embed(title=f"{lib.name.title()}: {final_query}", colour=lib.value[1])
291304
embed.description = "\n".join(out)
@@ -296,7 +309,7 @@ async def rtfs(self, ctx: core.Context, *, query: str) -> None:
296309

297310
else:
298311
n = next(iter(nodes.items()))
299-
await ctx.reply(f"Showing source for `{n[0]}`\nCommit: {matches['commit'][:6]}", mention_author=False)
312+
await self.context_reply(ctx, f"Showing source for `{n[0]}`\nCommit: {matches['commit'][:6]}", mention_author=False)
300313

301314
pages = TextPager(ctx, n[1], prefix="```py")
302315
await pages.paginate()

0 commit comments

Comments
 (0)