mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-11-14 18:11:23 +01:00
Fix handling discord user ban
This commit is contained in:
parent
05697402df
commit
930c026108
@ -180,10 +180,10 @@ class Titan(discord.AutoShardedClient):
|
||||
await self.database.update_guild_member(memberafter)
|
||||
await self.socketio.on_guild_member_update(memberafter)
|
||||
|
||||
async def on_member_ban(self, member):
|
||||
if self.user.id == member.id:
|
||||
async def on_member_ban(self, guild, user):
|
||||
if self.user.id == user.id:
|
||||
return
|
||||
await self.database.update_guild_member(member, active=False, banned=True)
|
||||
await self.database.update_guild_member(user, active=False, banned=True, guild=guild)
|
||||
|
||||
async def on_member_unban(self, guild, user):
|
||||
await self.database.unban_server_user(user, guild)
|
||||
|
@ -158,13 +158,19 @@ class DatabaseInterface(object):
|
||||
session.delete(gui)
|
||||
session.commit()
|
||||
|
||||
async def update_guild_member(self, member, active=True, banned=False):
|
||||
async def update_guild_member(self, member, active=True, banned=False, guild=None):
|
||||
async with threadpool():
|
||||
with self.get_session() as session:
|
||||
dbmember = session.query(GuildMembers) \
|
||||
.filter(GuildMembers.guild_id == int(member.guild.id)) \
|
||||
.filter(GuildMembers.user_id == int(member.id)) \
|
||||
.order_by(GuildMembers.id).all()
|
||||
if guild:
|
||||
dbmember = session.query(GuildMembers) \
|
||||
.filter(GuildMembers.guild_id == int(guild.id)) \
|
||||
.filter(GuildMembers.user_id == int(member.id)) \
|
||||
.order_by(GuildMembers.id).all()
|
||||
else:
|
||||
dbmember = session.query(GuildMembers) \
|
||||
.filter(GuildMembers.guild_id == int(member.guild.id)) \
|
||||
.filter(GuildMembers.user_id == int(member.id)) \
|
||||
.order_by(GuildMembers.id).all()
|
||||
if not dbmember:
|
||||
dbmember = GuildMembers(
|
||||
int(member.guild.id),
|
||||
|
Loading…
Reference in New Issue
Block a user