Skip to content

Commit

Permalink
Merge pull request #42 from eibex/fix-db
Browse files Browse the repository at this point in the history
Fix database errors on reaction add
  • Loading branch information
eibex authored Jun 29, 2020
2 parents 54368b1 + 1f49a89 commit de5ffb3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ async def on_message(message):
if error and system_channel:
await message.channel.send(
"I could not commit the changes to the database. Check"
f" {system_channel.mention} for more information."
f" the system channel for more information."
)
await system_notification(
message.channel.id,
Expand Down
11 changes: 5 additions & 6 deletions core/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,15 @@ def commit(self):
conn = sqlite3.connect(self.database)
cursor = conn.cursor()
cursor.execute(
"INSERT INTO 'messages' ('message_id', 'channel', 'reactionrole_id')"
" values(?, ?, ?);",
(self.message_id, self.target_channel, self.reactionrole_id),
"INSERT INTO 'messages' ('message_id', 'channel', 'reactionrole_id', 'guild_id')"
" values(?, ?, ?, ?);",
(self.message_id, self.target_channel, self.reactionrole_id, self.guild),
)
for reaction in self.combos:
role_id = self.combos[reaction]
cursor.execute(
"INSERT INTO 'reactionroles' ('reactionrole_id', 'reaction', 'role_id',"
" 'guild_id') values(?, ?, ?, ?);",
(self.reactionrole_id, reaction, role_id, self.guild),
"INSERT INTO 'reactionroles' ('reactionrole_id', 'reaction', 'role_id') values(?, ?, ?);",
(self.reactionrole_id, reaction, role_id),
)
conn.commit()
cursor.close()
Expand Down

0 comments on commit de5ffb3

Please sign in to comment.