Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions discord/ext/buttons/buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from discord.ext import commands
from functools import partial
from typing import Union
from datetime import datetime

__all__ = ('Session', 'Paginator', 'button', 'inverse_button',)

Expand Down Expand Up @@ -223,13 +224,15 @@ class Paginator(Session):
Only available when embed=True. The thumbnail URL to set for the embeded pages.
private: bool
if true send the author PM default is False
timestamp: bool
Only available when embed=True. add timestamp for the embed
"""

def __init__(self, *, title: str = '', length: int = 10, entries: list = None,
extra_pages: list = None, prefix: str = '', suffix: str = '', format: str = '',
colour: Union[int, discord.Colour] = discord.Embed.Empty,
color: Union[int, discord.Colour] = discord.Embed.Empty, use_defaults: bool = True, embed: bool = True,
joiner: str = '\n', timeout: int = 180, thumbnail: str = None, private: bool = False):
joiner: str = '\n', timeout: int = 180, thumbnail: str = None, private: bool = False, timestamp: bool = False):
super().__init__()
self._defaults = {(0, '⏮'): Button(emoji='⏮', position=0, callback=partial(self._default_indexer, 'start')),
(1, '◀'): Button(emoji='◀', position=1, callback=partial(self._default_indexer, -1)),
Expand Down Expand Up @@ -259,8 +262,9 @@ def __init__(self, *, title: str = '', length: int = 10, entries: list = None,
self.format = format
self.joiner = joiner
self.use_defaults = use_defaults
self.use_embed = embed
self.private = private
self.use_embed = embed
self.timestamp = timestamp

def chunker(self):
"""Create chunks of our entries for pagination."""
Expand Down Expand Up @@ -294,7 +298,8 @@ async def _paginate(self, ctx: commands.Context):
self._pages.append(self.joiner.join(chunk))
else:
embed = discord.Embed(title=self.title, description=self.joiner.join(chunk), colour=self.colour)

if self.timestamp:
embed.timestamp = datetime.utcnow()
if self.thumbnail:
embed.set_thumbnail(url=self.thumbnail)

Expand All @@ -312,7 +317,6 @@ async def _paginate(self, ctx: commands.Context):
self.page = await ctx.author.send(self._pages[0])
else:
self.page = await ctx.send(self._pages[0])

self._session_task = ctx.bot.loop.create_task(self._session(ctx))

async def _session(self, ctx):
Expand Down