SQL Lookup Tables will not initialize
Hello! Having issues with the setup, it looks like the channel crawler is trying to reference a value from the un-initialized channels table?
The only channel that populates is 'users', the subsequent SQL insertions all fail due to the tables not being initialized correctly. Is there a setup step I missed? Log:
[INFO] statbot.event: Initializing SQL lookup tables... [INFO] statbot.event: Processing X users... [INFO] statbot.event: Processing X guilds... [INFO] statbot.event: [INFO] statbot.event: Ready! [INFO] statbot.sql: Looking up channel crawl progress for {server} #{channel} [INFO] statbot.sql: Inserting new channel crawl progress for {server} #{channel} [ERROR] statbot.sql: Exception occurred in 'with' scope! Traceback (most recent call last): File ".../python3.9/site-packages/sqlalchemy/engine/base.py", line 1819, in _execute_context self.dialect.do_execute( File ".../python3.9/site-packages/sqlalchemy/engine/default.py", line 732, in do_execute cursor.execute(statement, parameters) psycopg2.errors.ForeignKeyViolation: insert or update on table "channel_crawl" violates foreign key constraint "channel_crawl_channel_id_fkey" DETAIL: Key (channel_id)=(1002...) is not present in table "channels".
In case somebody runs into this same issue, a few things:
-> First, drop the psql DB, if you've already run the initialization script.
-> Second, comment out any mention of voice_region in the code (deprecated)
-> Third, I also needed to change
for guild in set(self.guilds) & set(self.config["guild-ids"]): (Line 171 in client.py)
to:
for guild in set(self.guilds):
-> Then I just repeat the psql setup, ran the bot command, and it ran perfectly
Happy to submit a PR to get statbot to work with modern discord.py, if this project is still maintained. :)