mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-11-15 02:21:21 +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.database.update_guild_member(memberafter)
|
||||||
await self.socketio.on_guild_member_update(memberafter)
|
await self.socketio.on_guild_member_update(memberafter)
|
||||||
|
|
||||||
async def on_member_ban(self, member):
|
async def on_member_ban(self, guild, user):
|
||||||
if self.user.id == member.id:
|
if self.user.id == user.id:
|
||||||
return
|
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):
|
async def on_member_unban(self, guild, user):
|
||||||
await self.database.unban_server_user(user, guild)
|
await self.database.unban_server_user(user, guild)
|
||||||
|
@ -158,9 +158,15 @@ class DatabaseInterface(object):
|
|||||||
session.delete(gui)
|
session.delete(gui)
|
||||||
session.commit()
|
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():
|
async with threadpool():
|
||||||
with self.get_session() as session:
|
with self.get_session() as session:
|
||||||
|
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) \
|
dbmember = session.query(GuildMembers) \
|
||||||
.filter(GuildMembers.guild_id == int(member.guild.id)) \
|
.filter(GuildMembers.guild_id == int(member.guild.id)) \
|
||||||
.filter(GuildMembers.user_id == int(member.id)) \
|
.filter(GuildMembers.user_id == int(member.id)) \
|
||||||
|
Loading…
Reference in New Issue
Block a user