allow test channel, make database a class for easier use

This commit is contained in:
Philipp 2022-10-03 19:35:06 +02:00
parent b78b029855
commit 8b07505672
Signed by: Philipp
GPG key ID: 9EBD8439AFBAB750
2 changed files with 37 additions and 37 deletions

View file

@ -2,8 +2,8 @@ import os
import sys
import signal
import interactions
import database
from database import Database
from dotenv import load_dotenv
from steamid import SteamID
from loguru import logger
@ -23,7 +23,7 @@ class GracefulDeath:
for signum in catchSignals:
signal.signal(signum, self.handler)
def handler(self, signum, frame):
def handler(self, signum):
self.lastSignal=signum
self.receivedSignal=True
if signum in [2, 3, 15]:
@ -40,10 +40,10 @@ def main(args):
bot = interactions.Client(token=token)
mysql = database.create_connection(host, user, password, db)
con = Database(host, user, password, db)
try:
if args[0] == "init_database":
database.init_test_database(mysql)
con.init_test_database()
logger.info(f"First init of database... Please disable this afterwards with the flag init_dabase")
except:
logger.info(f"Skipping database init...")
@ -67,7 +67,7 @@ def main(args):
channel = ctx.channel.id
user = ctx.user
if channel != "433738529898627073":
if channel != "433738529898627073" and channel != "441985560144379912":
await ctx.send(f"This command only works in the Channel <#433738529898627073>!", ephemeral=True)
logger.debug(f"Command was used in the wrong channel. ({channel})")
return
@ -85,7 +85,7 @@ def main(args):
return
try:
database.create_reserved_slot(mysql, user, steam_id.steam2(1))
con.create_reserved_slot(user, steam_id.steam2(1))
await ctx.send(f"You just claimed a reserved slot for: `{steam_id.steam2(1)}`!")
logger.debug(f"{user.id} with SteamID: {steam_id.steam2(1)} has just claimed a reserved slot.")
except Exception as err: