From f979b8c4c1822cefe35fd2d7727e4b0d38dffd9d Mon Sep 17 00:00:00 2001 From: Mylloon Date: Tue, 6 Feb 2024 12:04:55 +0100 Subject: [PATCH] Modifications * stderr * Refactor * Rename db from sqlite3 to sqlite extension --- .gitignore | 2 +- src/modules/commandes.py | 5 +---- src/utils/commands.py | 2 +- src/utils/db.py | 5 +++-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 28978d7..f72f696 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,4 @@ __pycache__ .vscode/ .env -*.sqlite3 +*.sqlite diff --git a/src/modules/commandes.py b/src/modules/commandes.py index 0a6ac8e..8c910a1 100644 --- a/src/modules/commandes.py +++ b/src/modules/commandes.py @@ -21,9 +21,6 @@ class Commandes(Cog): self.prefix = load(["PREFIX"])["PREFIX"] self.not_a_mod = "tu n'es pas modérateur" self.unknown_command = "cette commande n'existe pas" - self.existing_command = ( - f"cette commande existe déjà, {self.prefix}edit pour l'éditer" - ) @new(name="add", aliases=["ajout", "ajouter"], no_global_checks=True) async def _add( @@ -43,7 +40,7 @@ class Commandes(Cog): CommandesDB().ajoutCommande(name, message) await ctx.send(f"@{ctx.author.name}, commande {name} ajoutée !") else: - await ctx.send(f"@{ctx.author.name}, {self.existing_command}.") + await ctx.send(f"@{ctx.author.name}, cette commande existe déjà.") else: await ctx.send(f"@{ctx.author.name}, {self.not_a_mod}.") diff --git a/src/utils/commands.py b/src/utils/commands.py index d1d11bf..9e4bf1c 100644 --- a/src/utils/commands.py +++ b/src/utils/commands.py @@ -5,7 +5,7 @@ from utils.db import Database class CommandesDB(Database): def __init__(self): - super().__init__(r"db/bot.sqlite3") + super().__init__(r"db/bot.sqlite") def creationTable(self) -> None: """Créer la table qui stocker les commandes.""" diff --git a/src/utils/db.py b/src/utils/db.py index 6d2f9bb..ce8453e 100644 --- a/src/utils/db.py +++ b/src/utils/db.py @@ -1,4 +1,5 @@ from sqlite3 import Connection, Cursor, Error, connect +from sys import stderr class Database: @@ -18,7 +19,7 @@ class Database: try: connnexion = connect(path) except Error as e: - print(e) + print(e, file=stderr) return connnexion def _fileExists(self, path: str) -> bool: @@ -45,7 +46,7 @@ class Database: self.connexion.commit() return (curseur, curseur.lastrowid) except Error as e: - print(e) + print(e, file=stderr) def getResults(self, curseur: _cursor) -> list[tuple]: """Affiche le résultat d'une requête"""