aboutsummaryrefslogtreecommitdiff
path: root/code/cogs
diff options
context:
space:
mode:
Diffstat (limited to 'code/cogs')
-rw-r--r--code/cogs/owner/stats.py13
1 files changed, 4 insertions, 9 deletions
diff --git a/code/cogs/owner/stats.py b/code/cogs/owner/stats.py
index 258b102..5409bfb 100644
--- a/code/cogs/owner/stats.py
+++ b/code/cogs/owner/stats.py
@@ -14,13 +14,11 @@ class Stats(commands.Cog):
if not os.path.exists("data"):
os.makedirs("data")
- connection = sqlite3.connect("data/count.db")
- if not connection:
- LOG.error(
- "Could not create connection to database. Likely permissions"
- " issue."
- )
+ if not os.access("data/count.db", os.W_OK):
+ LOG.error("Cannot write to data/count.db - check permissions")
+ return
+ connection = sqlite3.connect("data/count.db")
cursor = connection.cursor()
cursor.execute(
"CREATE TABLE IF NOT EXISTS count (command_name, count, PRIMARY"
@@ -34,9 +32,6 @@ class Stats(commands.Cog):
@tasks.loop(seconds=30)
async def dump_count(self):
connection = sqlite3.connect("data/count.db")
- if not connection:
- LOG.warning("No database connection. Skipping dump.")
-
cursor = connection.cursor()
for command_name, count in self.bot.temp_command_count.items():