Change bot to use update query.
build_latest / build (push) Successful in 48s
build_develop / build (push) Successful in 50s

This commit is contained in:
2023-11-07 14:59:07 -05:00
parent 8c1eb8d11f
commit b0e3162123
+4 -4
View File
@@ -7,7 +7,7 @@ from typing import List
import nextcord import nextcord
from nextcord import SelectOption from nextcord import SelectOption
from nextcord.interactions import Interaction from nextcord.interactions import Interaction
from sqlalchemy import exc, select from sqlalchemy import exc, select, update
from sqlalchemy.orm import Session from sqlalchemy.orm import Session
from config import DakinyConfig from config import DakinyConfig
@@ -56,12 +56,12 @@ class VoteSelect(nextcord.ui.StringSelect):
except exc.IntegrityError: except exc.IntegrityError:
session.rollback() session.rollback()
stmt = ( stmt = (
select(Votes) update(Votes)
.where(Votes.ElectionCycle == election_name) .where(Votes.ElectionCycle == election_name)
.where(Votes.VoterId == interaction.user.id) .where(Votes.VoterId == interaction.user.id)
.values(VotedForId=voted_for)
) )
vote = session.scalar(stmt) session.execute(stmt)
vote.VotedForId = voted_for
session.commit() session.commit()
vote_message_str = build_votes_str(self.config) vote_message_str = build_votes_str(self.config)