diff --git a/discord/ext/pages/pagination.py b/discord/ext/pages/pagination.py index f4bc79f12d..fcedf3bb88 100644 --- a/discord/ext/pages/pagination.py +++ b/discord/ext/pages/pagination.py @@ -605,6 +605,9 @@ async def send( ctx: Context, target: Optional[discord.abc.Messageable] = None, target_message: Optional[str] = None, + reference: Optional[Union[discord.Message, discord.MessageReference, discord.PartialMessage]] = None, + allowed_mentions: Optional[discord.AllowedMentions] = None, + mention_author: bool = None, ) -> discord.Message: """Sends a message with the paginated items. @@ -616,6 +619,20 @@ async def send( A target where the paginated message should be sent, if different from the original :class:`Context` target_message: Optional[:class:`str`] An optional message shown when the paginator message is sent elsewhere. + reference: Optional[Union[:class:`discord.Message`, :class:`discord.MessageReference`, :class:`discord.PartialMessage`]] + A reference to the :class:`~discord.Message` to which you are replying with the paginator. This can be created using + :meth:`~discord.Message.to_reference` or passed directly as a :class:`~discord.Message`. You can control + whether this mentions the author of the referenced message using the :attr:`~discord.AllowedMentions.replied_user` + attribute of ``allowed_mentions`` or by setting ``mention_author``. + allowed_mentions: Optional[:class:`~discord.AllowedMentions`] + Controls the mentions being processed in this message. If this is + passed, then the object is merged with :attr:`~discord.Client.allowed_mentions`. + The merging behaviour only overrides attributes that have been explicitly passed + to the object, otherwise it uses the attributes set in :attr:`~discord.Client.allowed_mentions`. + If no object is passed at all then the defaults given by :attr:`~discord.Client.allowed_mentions` + are used instead. + mention_author: Optional[:class:`bool`] + If set, overrides the :attr:`~discord.AllowedMentions.replied_user` attribute of ``allowed_mentions``. Returns -------- @@ -628,6 +645,17 @@ async def send( if target is not None and not isinstance(target, discord.abc.Messageable): raise TypeError(f"expected abc.Messageable not {target.__class__!r}") + if reference is not None and not isinstance( + reference, (discord.Message, discord.MessageReference, discord.PartialMessage) + ): + raise TypeError(f"expected Message, MessageReference, or PartialMessage not {reference.__class__!r}") + + if allowed_mentions is not None and not isinstance(allowed_mentions, discord.AllowedMentions): + raise TypeError(f"expected AllowedMentions not {allowed_mentions.__class__!r}") + + if mention_author is not None and not isinstance(mention_author, bool): + raise TypeError(f"expected bool not {mention_author.__class__!r}") + self.update_buttons() page = self.pages[self.current_page] page = self.get_page_content(page) @@ -636,13 +664,21 @@ async def send( if target: if target_message: - await ctx.send(target_message) + await ctx.send( + target_message, + reference=reference, + allowed_mentions=allowed_mentions, + mention_author=mention_author, + ) ctx = target self.message = await ctx.send( content=page if isinstance(page, str) else None, embeds=[] if isinstance(page, str) else page, view=self, + reference=reference, + allowed_mentions=allowed_mentions, + mention_author=mention_author, ) return self.message