mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-11-15 02:21:21 +01:00
Add emoji capability to bot
This commit is contained in:
parent
edfcb63706
commit
f25669e1bc
@ -161,3 +161,9 @@ class Titan(discord.Client):
|
||||
|
||||
async def on_member_unban(self, server, user):
|
||||
await self.database.unban_server_user(user, server)
|
||||
|
||||
async def on_server_emojis_update(self, before, after):
|
||||
if len(after) == 0:
|
||||
await self.database.update_guild(before[0].server)
|
||||
else:
|
||||
await self.database.update_guild(after[0].server)
|
||||
|
@ -126,6 +126,7 @@ class DatabaseInterface(object):
|
||||
guild.name,
|
||||
json.dumps(self.get_roles_list(guild.roles)),
|
||||
json.dumps(self.get_channels_list(guild.channels)),
|
||||
json.dumps(self.get_emojis_list(guild.emojis)),
|
||||
guild.owner_id,
|
||||
guild.icon
|
||||
)
|
||||
@ -134,9 +135,23 @@ class DatabaseInterface(object):
|
||||
gui.name = guild.name
|
||||
gui.roles = json.dumps(self.get_roles_list(guild.roles))
|
||||
gui.channels = json.dumps(self.get_channels_list(guild.channels))
|
||||
gui.emojis = json.dumps(self.get_emojis_list(guild.emojis))
|
||||
gui.owner_id = guild.owner_id
|
||||
gui.icon = guild.icon
|
||||
session.commit()
|
||||
|
||||
def get_emojis_list(self, guildemojis):
|
||||
emojis = []
|
||||
for emote in guildemojis:
|
||||
emojis.append({
|
||||
"id": emote.id,
|
||||
"name": emote.name,
|
||||
"require_colons": emote.require_colons,
|
||||
"managed": emote.managed,
|
||||
"roles": self.list_role_ids(emote.roles),
|
||||
"url": emote.url
|
||||
})
|
||||
return emojis
|
||||
|
||||
def get_roles_list(self, guildroles):
|
||||
roles = []
|
||||
|
@ -11,10 +11,11 @@ class Guilds(Base):
|
||||
mentions_limit = db.Column(db.Integer) # If there is a limit on the number of mentions in a msg
|
||||
roles = db.Column(db.Text()) # Guild Roles
|
||||
channels = db.Column(db.Text()) # Guild channels
|
||||
emojis = db.Column(db.Text()) # Guild Emojis
|
||||
owner_id = db.Column(db.String(255)) # Snowflake of the owner
|
||||
icon = db.Column(db.String(255)) # The icon string, null if none
|
||||
|
||||
def __init__(self, guild_id, name, roles, channels, owner_id, icon):
|
||||
def __init__(self, guild_id, name, roles, channels, emojis, owner_id, icon):
|
||||
self.guild_id = guild_id
|
||||
self.name = name
|
||||
self.unauth_users = True # defaults to true
|
||||
@ -23,6 +24,7 @@ class Guilds(Base):
|
||||
self.mentions_limit = -1 # -1 = unlimited mentions
|
||||
self.roles = roles
|
||||
self.channels = channels
|
||||
self.emojis = emojis
|
||||
self.owner_id = owner_id
|
||||
self.icon = icon
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user