removing a call to the database
This commit is contained in:
parent
12d4c833dd
commit
a7b1defaad
2 changed files with 17 additions and 13 deletions
|
@ -150,7 +150,7 @@ class ReminderDiscord(commands.Cog):
|
|||
if fromSlash != True:
|
||||
await ctx.message.add_reaction(emoji = '✅')
|
||||
|
||||
embed, pageMAX, refresh = embedListe(utilisateur, ctx.guild.id, page)
|
||||
embed, pageMAX, refresh = await embedListe(utilisateur, ctx.guild.id, page)
|
||||
message = await ctx.send(embed = embed)
|
||||
if refresh:
|
||||
await message.add_reaction("🔄")
|
||||
|
|
|
@ -70,11 +70,19 @@ class Reminder(Database):
|
|||
"""
|
||||
return True if self.affichageResultat(self.requete(requete, [id, userID, guildID]))[0][0] == 1 else False
|
||||
|
||||
def embedListe(utilisateur, guildID, page, color = None):
|
||||
async def embedListe(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)
|
||||
|
||||
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:
|
||||
return (False, False, False)
|
||||
|
||||
if pageMAX > 1:
|
||||
refresh = False
|
||||
else:
|
||||
|
@ -119,6 +127,7 @@ async def listReaction(client, payload):
|
|||
infoDescription = findall(r"\*\*Rappels? de <@\!?(\d+)>\*\* • Page (\d+)\/(\d+)", embed["description"])[0]
|
||||
utilisateur = client.get_user(int(infoDescription[0]))
|
||||
page = int(infoDescription[1])
|
||||
refresh_message = None
|
||||
if payload.emoji.name == "⬅️":
|
||||
if page > 1:
|
||||
page -= 1
|
||||
|
@ -133,16 +142,11 @@ async def listReaction(client, payload):
|
|||
else:
|
||||
return False, False
|
||||
if payload.emoji.name == "🔄":
|
||||
reminders = Reminder().listeReminder(utilisateur.id, payload.guild_id)
|
||||
if len(reminders) > 0:
|
||||
page = 1
|
||||
if -(-len(reminders) // 5) > 1 and message.reactions[0] != "⬅️":
|
||||
for emoji in ["⬅️", "➡️"]:
|
||||
await message.add_reaction(emoji)
|
||||
else:
|
||||
return False, False
|
||||
embed, _, refresh = embedListe(utilisateur, payload.guild_id, page, embed["color"])
|
||||
if refresh:
|
||||
refresh_message = message
|
||||
embed, _, refresh = await embedListe(utilisateur, payload.guild_id, page, embed["color"], refresh_message)
|
||||
if embed == False:
|
||||
return False, False
|
||||
if refresh == True:
|
||||
await message.add_reaction("🔄")
|
||||
else:
|
||||
for reaction in message.reactions:
|
||||
|
|
Reference in a new issue