aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Leon Sandøy <[email protected]>2019-02-24 21:24:49 +0100
committerGravatar GitHub <[email protected]>2019-02-24 21:24:49 +0100
commit5ca9f10add1b80500396346eb6e6e0790407680b (patch)
tree7f51e4e59aca13bb37539c0b8acc0e04884d8055
parentMerge pull request #307 from python-discord/bb-improvements (diff)
parentChanging from footer to header url (diff)
Merge pull request #316 from Refisio/rules_command
Removed STAFF constant, added footer to paginated embed
-rw-r--r--bot/cogs/rules.py8
-rw-r--r--bot/pagination.py14
2 files changed, 17 insertions, 5 deletions
diff --git a/bot/cogs/rules.py b/bot/cogs/rules.py
index 1067f2758..b8a26ff76 100644
--- a/bot/cogs/rules.py
+++ b/bot/cogs/rules.py
@@ -52,6 +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.title_link = 'https://pythondiscord.com/about/rules'
@command(aliases=['r', 'rule'], name='rules')
@redirect_output(destination_channel=Channels.bot, bypass_roles=STAFF_ROLES)
@@ -64,11 +65,11 @@ class Rules:
**`rules`:** The rules a user wants to get.
"""
rules_embed = Embed(title='Rules', color=Colour.blurple())
- rules_embed.set_footer(text='https://pythondiscord.com/about/rules')
if not rules:
# Rules were not submitted. Return the default description.
rules_embed.description = self.default_desc
+ rules_embed.url = 'https://pythondiscord.com/about/rules'
return await ctx.send(embed=rules_embed)
# Split the rules input by slash, comma or space
@@ -93,7 +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)
+ 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)