diff --git a/geeksbot.py b/geeksbot.py index f8894bb..1fa4e88 100644 --- a/geeksbot.py +++ b/geeksbot.py @@ -57,16 +57,19 @@ class Geeksbot(commands.Bot): self.infected = {} self.TOKEN = self.bot_secrets['token'] del self.bot_secrets['token'] - self.db_con = asyncpg.connect(f"host={self.bot_secrets['db_con']['host']}\ - database={self.bot_secrets['db_con']['db_name']}\ - user={self.bot_secrets['db_con']['user']}\ - password={self.bot_secrets['db_con']['password']}") + self.db_con = self.connect_db(self) del self.bot_secrets['db_con'] self.default_prefix = 'g~' self.voice_chans = {} self.spam_list = {} self.gcs_service = build('customsearch', 'v1', developerKey=self.bot_secrets['google_search_key']) + async def connect_db(self): + return await asyncpg.connect(f"host={self.bot_secrets['db_con']['host']}\ + database={self.bot_secrets['db_con']['db_name']}\ + user={self.bot_secrets['db_con']['user']}\ + password={self.bot_secrets['db_con']['password']}") + @staticmethod async def get_custom_prefix(bot_inst, message): return await bot_inst.db_con.fetchval('select prefix from guild_config where guild_id = $1', diff --git a/geeksbot_launcher.sh b/geeksbot_launcher.sh index 7b28f8d..256b0e9 100644 --- a/geeksbot_launcher.sh +++ b/geeksbot_launcher.sh @@ -1,6 +1,6 @@ #!/bin/bash -until python /home/dusty/bin/geeksbot/geeksbot.py; do +until python /home/dusty/bin/geeksbot_dev/geeksbot.py; do echo "Geeksbot shutdown with error: $?. Restarting..." >&2 sleep 1 done