This commit is contained in:
Mylloon 2021-08-22 16:47:35 +02:00
parent 7f3b412953
commit 96783e03cf
2 changed files with 15 additions and 18 deletions

View file

@ -72,26 +72,25 @@ class Reminder(Database):
async def embedListeReminder(utilisateur, guildID, page, color = None, refresh_message = None):
"""Fais l'embed d'une page pour l'affichage de la liste des reminders d'un utilisateur."""
reminders = Reminder().listeReminder(utilisateur.id, guildID)
pageMAX = -(-len(reminders) // 5)
elementPerPage = 5
pageMAX = -(-len(reminders) // elementPerPage)
if refresh_message:
if len(reminders) > 0:
if pageMAX > 1 and refresh_message.reactions[0] != "⬅️":
for emoji in ["⬅️", "➡️"]:
await refresh_message.add_reaction(emoji)
else:
nothing = True
if pageMAX == 1:
if pageMAX <= 1:
page = 1 # force page 1
if color == None:
color = Colour.random()
embed = Embed(description = f"**Rappel{'s' if len(reminders) > 1 else ''} de {utilisateur.mention}** • Page {page}/{pageMAX}", color = color)
embed.set_thumbnail(url = utilisateur.avatar_url_as(size = 64))
limit = 5 * page
if (len(reminders) > 0 and page <= pageMAX) or not nothing:
curseur = limit - 4
for reminder in reminders[limit - 5:]:
limit = elementPerPage * page
if (len(reminders) > 0 and page <= pageMAX):
curseur = limit - (elementPerPage - 1)
for reminder in reminders[limit - elementPerPage:]:
if curseur <= limit:
texte = reminder[0]
if len(texte) > 1024:

View file

@ -60,31 +60,29 @@ class ToDo(Database):
async def embedListeToDo(utilisateur, page, color = None, refresh_message = None):
"""Fais l'embed d'une page pour l'affichage de la liste des To Do d'un utilisateur."""
todos = ToDo().liste(utilisateur.id)
pageMAX = -(-len(todos) // 5)
elementPerPage = 6
pageMAX = -(-len(todos) // elementPerPage)
if refresh_message:
if len(todos) > 0:
if pageMAX > 1 and refresh_message.reactions[0] != "⬅️":
for emoji in ["⬅️", "➡️"]:
await refresh_message.add_reaction(emoji)
else:
nothing = True
if pageMAX == 1:
if pageMAX <= 1:
page = 1 # force page 1
if color == None:
color = Colour.random()
s = "'s"
embed = Embed(description = f"**To Do{s if len(todos) > 1 else ''} de {utilisateur.mention}** • Page {page}/{pageMAX}", color = color)
embed.set_thumbnail(url = utilisateur.avatar_url_as(size = 64))
limit = 5 * page
if (len(todos) > 0 and page <= pageMAX) or not nothing:
curseur = limit - 4
for todo in todos[limit - 5:]:
limit = elementPerPage * page
if (len(todos) > 0 and page <= pageMAX):
curseur = limit - (elementPerPage - 1)
for todo in todos[limit - elementPerPage:]:
if curseur <= limit:
texte = todo[1]
if len(texte) > 1024:
texte = f"{texte[:1021]}..."
texte = f"{texte[:1021]}..."
embed.add_field(value = texte, name = f"#{todo[0]} • Fais le {timestampScreen(intToDatetime(todo[2]))}", inline = False)
curseur += 1
else: