check if command exist

This commit is contained in:
Mylloon 2021-07-29 01:45:17 +02:00
parent d68ed28bbf
commit 2a073723d5

View file

@ -14,7 +14,7 @@ class CommandesDB(Database):
"""
self.requete(requete)
def ajoutCommande(self, name = str, message = str):
def ajoutCommande(self, name: str, message: str):
"""Ajoute une commande."""
requete = """
INSERT INTO commandes (
@ -26,7 +26,7 @@ class CommandesDB(Database):
"""
self.requete(requete, [name, message])
def suppressionCommande(self, name = str):
def suppressionCommande(self, name: str):
"""Supprime une commande."""
requete = """
DELETE FROM commandes
@ -37,3 +37,10 @@ class CommandesDB(Database):
def listeCommande(self):
"""Retourne la liste des commandes."""
return self.affichageResultat(self.requete("SELECT * FROM commandes;"))
def existeCommande(self, command: str):
commandes = self.listeCommande()
for commande in commandes:
if commande[0] == command:
return (True, commande[1])
return (False,)