mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-11-15 02:21:21 +01:00
Try manually adding member if not exist in db for webapp
This commit is contained in:
parent
1fda98ac89
commit
d14f9889eb
@ -125,6 +125,11 @@ class DiscordREST:
|
|||||||
r = self.request("GET", _endpoint)
|
r = self.request("GET", _endpoint)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
def get_guild_member(self, guild_id, user_id):
|
||||||
|
_endpoint = "/guilds/{guild_id}/members/{user_id}".format(guild_id=guild_id, user_id=user_id)
|
||||||
|
r = self.request("GET", _endpoint)
|
||||||
|
return r
|
||||||
|
|
||||||
def modify_guild_embed(self, guild_id, **kwargs):
|
def modify_guild_embed(self, guild_id, **kwargs):
|
||||||
_endpoint = "/guilds/{guild_id}/embed".format(guild_id=guild_id)
|
_endpoint = "/guilds/{guild_id}/embed".format(guild_id=guild_id)
|
||||||
r = self.request("PATCH", _endpoint, data=kwargs, json=True)
|
r = self.request("PATCH", _endpoint, data=kwargs, json=True)
|
||||||
|
@ -195,7 +195,17 @@ def check_user_in_guild(guild_id):
|
|||||||
|
|
||||||
def get_member_roles(guild_id, user_id):
|
def get_member_roles(guild_id, user_id):
|
||||||
q = db.session.query(GuildMembers).filter(GuildMembers.guild_id == guild_id).filter(GuildMembers.user_id == user_id).first()
|
q = db.session.query(GuildMembers).filter(GuildMembers.guild_id == guild_id).filter(GuildMembers.user_id == user_id).first()
|
||||||
return json.loads(q.roles)
|
roles = [guild_id]
|
||||||
|
if not q:
|
||||||
|
member = discord_api.get_guild_member(guild_id, user_id)
|
||||||
|
if member["success"]:
|
||||||
|
roles = list(map(int, member["content"]["roles"]))
|
||||||
|
member = GuildMembers(guild_id, user_id, member["content"]["user"]["username"], int(member["content"]["user"]["discriminator"]), member["content"].get("nick", None), member["content"]["user"]["avatar"], True, False, roles)
|
||||||
|
db.session.add(member)
|
||||||
|
db.session.commit()
|
||||||
|
else:
|
||||||
|
roles = json.loads(q.roles)
|
||||||
|
return roles
|
||||||
|
|
||||||
def get_guild_channels(guild_id, force_everyone=False):
|
def get_guild_channels(guild_id, force_everyone=False):
|
||||||
if user_unauthenticated() or force_everyone:
|
if user_unauthenticated() or force_everyone:
|
||||||
|
Loading…
Reference in New Issue
Block a user