check if DM are closed and don't stop at first error

This commit is contained in:
Mylloon 2021-09-20 11:14:51 +02:00
parent dac6ed6112
commit abd62d7c6d

View file

@ -34,10 +34,13 @@ class ToDoDiscord(commands.Cog, name="Todo"):
for todo in todos: for todo in todos:
user = self.client.get_user(todo[0]) user = self.client.get_user(todo[0])
if user == None: # si l'utilisateur n'est pas trouvé if user == None: # si l'utilisateur n'est pas trouvé
return # on ignore l'utilisateur pass # on ignore l'utilisateur
channel = await user.create_dm() # envoie en DM channel = await user.create_dm() # envoie en DM
embed, pageMAX = await embedListeToDo(user, 1) embed, pageMAX = await embedListeToDo(user, 1)
message = await channel.send("Récapitulatif hebdomadaire de vos To Do's", embed = embed) try:
message = await channel.send("Récapitulatif hebdomadaire de vos To Do's", embed = embed)
except: # Les DM sont fermés
pass # on ignore l'envoie du récap
if pageMAX > 1: if pageMAX > 1:
for emoji in ["⬅️", "➡️"]: for emoji in ["⬅️", "➡️"]:
await message.add_reaction(emoji) await message.add_reaction(emoji)