ajout méthode pour vérifier l'appartenance d'un rappel à un user
This commit is contained in:
parent
8e0f067062
commit
7d06794d93
1 changed files with 17 additions and 5 deletions
|
@ -5,7 +5,7 @@ class Reminder(Database):
|
|||
super().__init__(r"db/bot.sqlite3")
|
||||
|
||||
def creationTable(self):
|
||||
"""Créer la table qui stocker les reminders"""
|
||||
"""Créer la table qui stocker les reminders."""
|
||||
requete = """
|
||||
CREATE TABLE IF NOT EXISTS reminder (
|
||||
id INTEGER PRIMARY KEY,
|
||||
|
@ -22,7 +22,7 @@ class Reminder(Database):
|
|||
self.requete(requete)
|
||||
|
||||
def ajoutReminder(self, messageID = int, channelID = int, mention = int, reminder = str, creation = int, expiration = int, userID = int, guildID = int):
|
||||
"""Ajoute un reminder"""
|
||||
"""Ajoute un reminder."""
|
||||
requete = """
|
||||
INSERT INTO reminder (
|
||||
message_id, channel_id, extrarg_id, reminder_str, creation_int, expiration_int, user_id, guild_id
|
||||
|
@ -33,7 +33,7 @@ class Reminder(Database):
|
|||
self.requete(requete, [messageID, channelID, mention, reminder, creation, expiration, userID, guildID])
|
||||
|
||||
def suppressionReminder(self, id = int):
|
||||
"""Supprime un reminder"""
|
||||
"""Supprime un reminder."""
|
||||
requete = """
|
||||
DELETE FROM reminder
|
||||
WHERE id = ?
|
||||
|
@ -41,7 +41,7 @@ class Reminder(Database):
|
|||
self.requete(requete, id)
|
||||
|
||||
def listeReminder(self, userID = int, guildID = int):
|
||||
"""Retourne la liste des reminders d'un utilisateur"""
|
||||
"""Retourne la liste des reminders d'un utilisateur."""
|
||||
requete = """
|
||||
SELECT reminder_str, creation_int, expiration_int, id FROM reminder
|
||||
WHERE user_id = ? AND guild_id = ?
|
||||
|
@ -49,9 +49,21 @@ class Reminder(Database):
|
|||
return self.affichageResultat(self.requete(requete, [userID, guildID]))
|
||||
|
||||
def recuperationExpiration(self, time = int):
|
||||
"""Récupère les reminders qui sont arrivés à expiration et ses infos"""
|
||||
"""Récupère les reminders qui sont arrivés à expiration et ses infos."""
|
||||
requete = """
|
||||
SELECT channel_id, extrarg_id, reminder_str, creation_int, user_id, id, message_id FROM reminder
|
||||
WHERE expiration_int < ?
|
||||
"""
|
||||
return self.affichageResultat(self.requete(requete, time))
|
||||
|
||||
def appartenanceReminder(self, user = int, id = int):
|
||||
"""Vérifie qu'un rappel appartiens à un utilisateur. Renvois False si le rappel n'existe pas."""
|
||||
requete = """
|
||||
SELECT user_id, id, message_id FROM reminder
|
||||
WHERE id = ? AND user_id = ?
|
||||
"""
|
||||
resultat = self.affichageResultat(self.requete(requete, [id, user]))
|
||||
if len(resultat) > 0:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
|
Reference in a new issue