aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Leon Sandøy <[email protected]>2019-02-24 21:11:28 +0100
committerGravatar Leon Sandøy <[email protected]>2019-02-24 21:11:28 +0100
commitd084925c5700ad020a688d9e832c6cbb9ed675ee (patch)
tree7f51e4e59aca13bb37539c0b8acc0e04884d8055
parentMerge branch 'master' into rules_command (diff)
Changing from footer to header url
-rw-r--r--bot/cogs/rules.py10
-rw-r--r--bot/pagination.py14
2 files changed, 17 insertions, 7 deletions
diff --git a/bot/cogs/rules.py b/bot/cogs/rules.py
index dbf236114..b8a26ff76 100644
--- a/bot/cogs/rules.py
+++ b/bot/cogs/rules.py
@@ -52,7 +52,7 @@ class Rules:
" our [rules page](https://pythondiscord.com/about/rules). We expect"
" all members of the community to have read and understood these."
)
- self.footer = 'https://pythondiscord.com/about/rules'
+ self.title_link = 'https://pythondiscord.com/about/rules'
@command(aliases=['r', 'rule'], name='rules')
@redirect_output(destination_channel=Channels.bot, bypass_roles=STAFF_ROLES)
@@ -69,7 +69,7 @@ class Rules:
if not rules:
# Rules were not submitted. Return the default description.
rules_embed.description = self.default_desc
- rules_embed.set_footer(text=self.footer)
+ rules_embed.url = 'https://pythondiscord.com/about/rules'
return await ctx.send(embed=rules_embed)
# Split the rules input by slash, comma or space
@@ -94,8 +94,10 @@ class Rules:
# No valid rules in rules input. Return the default description.
rules_embed.description = self.default_desc
return await ctx.send(embed=rules_embed)
- await LinePaginator.paginate(final_rules, ctx, rules_embed, max_lines=3,
- footer_text=self.footer)
+ await LinePaginator.paginate(
+ final_rules, ctx, rules_embed,
+ max_lines=3, url=self.title_link
+ )
def setup(bot):
diff --git a/bot/pagination.py b/bot/pagination.py
index 72cfd83ef..0ad5b81f1 100644
--- a/bot/pagination.py
+++ b/bot/pagination.py
@@ -100,8 +100,7 @@ class LinePaginator(Paginator):
async def paginate(cls, lines: Iterable[str], ctx: Context, embed: Embed,
prefix: str = "", suffix: str = "", max_lines: Optional[int] = None, max_size: int = 500,
empty: bool = True, restrict_to_user: User = None, timeout: int = 300,
- footer_text: str = None,
- exception_on_empty_embed: bool = False):
+ footer_text: str = None, url: str = None, exception_on_empty_embed: bool = False):
"""
Use a paginator and set of reactions to provide pagination over a set of lines. The reactions are used to
switch page, or to finish with pagination.
@@ -123,6 +122,8 @@ class LinePaginator(Paginator):
:param max_size: The maximum number of characters on each page
:param empty: Whether to place an empty line between each given line
:param restrict_to_user: A user to lock pagination operations to for this message, if supplied
+ :param exception_on_empty_embed: Should there be an exception if the embed is empty?
+ :param url: the url to use for the embed headline
:param timeout: The amount of time in seconds to disable pagination of no reaction is added
:param footer_text: Text to prefix the page number in the footer with
"""
@@ -182,6 +183,10 @@ class LinePaginator(Paginator):
embed.set_footer(text=footer_text)
log.trace(f"Setting embed footer to '{footer_text}'")
+ if url:
+ embed.url = url
+ log.trace(f"Setting embed url to '{url}'")
+
log.debug("There's less than two pages, so we won't paginate - sending single page on its own")
return await ctx.send(embed=embed)
else:
@@ -189,9 +194,12 @@ class LinePaginator(Paginator):
embed.set_footer(text=f"{footer_text} (Page {current_page + 1}/{len(paginator.pages)})")
else:
embed.set_footer(text=f"Page {current_page + 1}/{len(paginator.pages)}")
-
log.trace(f"Setting embed footer to '{embed.footer.text}'")
+ if url:
+ embed.url = url
+ log.trace(f"Setting embed url to '{url}'")
+
log.debug("Sending first page to channel...")
message = await ctx.send(embed=embed)