diff options
author | Parker <contact@pkrm.dev> | 2024-11-19 21:40:23 -0600 |
---|---|---|
committer | Parker <contact@pkrm.dev> | 2024-11-19 21:40:23 -0600 |
commit | d97ab8b34e5bed801fe9fcbeaa35d82a6c99f575 (patch) | |
tree | e95ef27fa6bcbbde353e6861daebdf9ee61948ad | |
parent | 226a5cd118dfcdef2e0feacf6375ecf03b0b6ba3 (diff) |
Print error/warning if database connection cannot be made
-rw-r--r-- | code/cogs/owner/stats.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/code/cogs/owner/stats.py b/code/cogs/owner/stats.py index 4bf41f8..258b102 100644 --- a/code/cogs/owner/stats.py +++ b/code/cogs/owner/stats.py @@ -3,7 +3,7 @@ import sqlite3 import discord import os -from utils.config import BOT_COLOR +from utils.config import BOT_COLOR, LOG class Stats(commands.Cog): @@ -15,6 +15,12 @@ class Stats(commands.Cog): os.makedirs("data") connection = sqlite3.connect("data/count.db") + if not connection: + LOG.error( + "Could not create connection to database. Likely permissions" + " issue." + ) + cursor = connection.cursor() cursor.execute( "CREATE TABLE IF NOT EXISTS count (command_name, count, PRIMARY" @@ -28,6 +34,9 @@ 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(): |