Skip to content

Reviewing main so far - #4

Draft
Rocked03 wants to merge 75 commits into
review-basefrom
main
Draft

Reviewing main so far#4
Rocked03 wants to merge 75 commits into
review-basefrom
main

Conversation

@Rocked03

@Rocked03 Rocked03 commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

don't merge, just using this to add comments

@Rocked03 Rocked03 self-assigned this Jul 9, 2026
Added detailed information about the Amalgam Discord bot, including its functionality, setup instructions, configuration, permissions, and requirements.

@Rocked03 Rocked03 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking pretty sweet so far! I think we can do a decent bit to tidy it up though so that's what most of my comments are surrounding. lmk if you want me to explain anything clearer :)

Comment thread cogs/review.py
Comment thread cogs/review.py
Comment thread cogs/review.py
Comment on lines +43 to +65
self.conn = sqlite3.connect("forward_reviews.db")
self.cursor = self.conn.cursor()

# Create tables if missing
# forward_reviews stores all db info needed to forward, edit and delete reviews
self.cursor.execute("""
CREATE TABLE IF NOT EXISTS forward_reviews (
original_id INTEGER PRIMARY KEY,
mirrored_channel_id INTEGER NOT NULL,
mirrored_id INTEGER NOT NULL
)
""")
self.conn.commit()

# forward_threads stores all db info needed to determine what original thread belongs to what mirrored thread. This info is used in cog threads.py
self.cursor.execute("""
CREATE TABLE IF NOT EXISTS forward_threads (
original_thread_id INTEGER PRIMARY KEY,
mirrored_thread_id INTEGER NOT NULL,
owner_id INTEGER NOT NULL
)
""")
self.conn.commit()

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few things:

  • these should belong in their own function
  • these should all be async as well otherwise we could have blocking issues
  • this is duplicated in threads.py which is typically just a code smell but because these are database operations being triggered automatically we gotta make sure we're not just creating a race condition

Comment thread cogs/review.py
Comment thread cogs/review.py
Comment thread cogs/review.py
Comment on lines +49 to +53
CREATE TABLE IF NOT EXISTS forward_reviews (
original_id INTEGER PRIMARY KEY,
mirrored_channel_id INTEGER NOT NULL,
mirrored_id INTEGER NOT NULL
)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can be a bit clearer with how we design our database here

Our main object here is a review, so that should live in a reviews table. The only information specific to a review is:

  • the review message ID
  • the review message guild
  • the review author ID
  • for each mirror
    • the mirror message ID
    • the mirror message guild
    • (n.b. I know we only have one place we're mirroring to, but we should design with the ability to expand rather than fixing us in a spot where we can only mirror to one place)

This means our reviews table should only include the original message ID (primary (unique) key) and guild ID.

We should then have a separate table that forms our 1:N relationship, which we could call something like review_mirrors-- basically what we have currently. This table would have

  • the original review message ID (primary key)
  • the mirrored guild ID
    • also primary key, so they become a primary key pair ie you can have multiple rows with the same message ID or same guild ID but each pair is unique
  • the mirrored review message ID
    And then when we use this we can fetch all rows matching the review message ID and edit mirrors for each guild listed

We can also ditch the threads table because thread channel IDs are identical to the message ID that the thread is created on

And we could also potentially even have a guilds table with guild ID (PK) and channel ID so that we have a solid mapping from guild ID to channel ID, meaning we can use the guild ID in the above tables rather than sorting things by individual channel. (and just then use LEFT JOIN when we make our queries)

This might be a little confusing, lmk if you want me to try to explain this better (hopefully with less 1am brain 😅)

Comment thread cogs/threads.py
import sqlite3


class ThreadCog(commands.Cog) :

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a lot of my comments in review.py are also applicable here, largely due to a lot of the code being duplicated

a lot of the time, it's possible to deduplicate code, typically by moving it into a shared location

also I won't duplicate too many comments in here if I've already mentioned it in review.py but please do make sure you make changes in here too if relevant

Comment thread cogs/threads.py
Comment on lines +19 to +41
# Open database
self.conn = sqlite3.connect("forward_reviews.db")
self.cursor = self.conn.cursor()

# Create tables if missing
# forward_threads stores all db info needed to determine what original thread belongs to what mirrored thread. This info is gathered in cog review.py
self.cursor.execute("""
CREATE TABLE IF NOT EXISTS forward_threads (
original_thread_id INTEGER PRIMARY KEY,
mirrored_thread_id INTEGER NOT NULL,
owner_id INTEGER NOT NULL
)
""")
self.conn.commit()

# forward_thread_messages stores all db info needed to determine what original thread belongs to what mirrored thread
self.cursor.execute("""
CREATE TABLE IF NOT EXISTS forward_thread_messages (
original_thread_message_id INTEGER PRIMARY KEY,
mirrored_thread_message_id INTEGER NOT NULL
)
""")
self.conn.commit()

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will reiterate here that this should really be moved into some shared helper class

Comment thread main.py
Comment thread main.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants