mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-11-15 02:21:21 +01:00
Guild member duplicate checking in the database
This commit is contained in:
parent
70aae0ab22
commit
c42f808715
@ -158,7 +158,8 @@ class DatabaseInterface(object):
|
|||||||
with self.get_session() as session:
|
with self.get_session() as session:
|
||||||
dbmember = session.query(GuildMembers) \
|
dbmember = session.query(GuildMembers) \
|
||||||
.filter(GuildMembers.guild_id == member.server.id) \
|
.filter(GuildMembers.guild_id == member.server.id) \
|
||||||
.filter(GuildMembers.user_id == member.id).first()
|
.filter(GuildMembers.user_id == member.id) \
|
||||||
|
.order_by(GuildMembers.id).all()
|
||||||
if not dbmember:
|
if not dbmember:
|
||||||
dbmember = GuildMembers(
|
dbmember = GuildMembers(
|
||||||
member.server.id,
|
member.server.id,
|
||||||
@ -173,6 +174,10 @@ class DatabaseInterface(object):
|
|||||||
)
|
)
|
||||||
session.add(dbmember)
|
session.add(dbmember)
|
||||||
else:
|
else:
|
||||||
|
if len(dbmember) > 1:
|
||||||
|
for mem in dbmember[1:]:
|
||||||
|
session.delete(mem)
|
||||||
|
dbmember = dbmember[0]
|
||||||
dbmember.banned = banned
|
dbmember.banned = banned
|
||||||
dbmember.active = active
|
dbmember.active = active
|
||||||
dbmember.username = member.name
|
dbmember.username = member.name
|
||||||
|
Loading…
Reference in New Issue
Block a user