Display rich embed support

This commit is contained in:
Jeremy Zhang
2017-11-05 05:59:06 +00:00
parent 962880f652
commit eff2b3bb46
8 changed files with 240 additions and 8 deletions

View File

@ -14,8 +14,9 @@ class Messages(db.Model):
edited_timestamp = db.Column(db.TIMESTAMP) # Timestamp of when content is edited
mentions = db.Column(db.Text()) # Mentions serialized
attachments = db.Column(db.Text()) # serialized attachments
embeds = db.Column(db.Text().with_variant(db.Text(length=4294967295), 'mysql')) # message embeds
def __init__(self, guild_id, channel_id, message_id, content, author, timestamp, edited_timestamp, mentions, attachments):
def __init__(self, guild_id, channel_id, message_id, content, author, timestamp, edited_timestamp, mentions, attachments, embeds):
self.guild_id = guild_id
self.channel_id = channel_id
self.message_id = message_id
@ -25,6 +26,7 @@ class Messages(db.Model):
self.edited_timestamp = edited_timestamp
self.mentions = mentions
self.attachments = attachments
self.embeds = embeds
def __repr__(self):
return '<Messages {0} {1} {2} {3} {4}>'.format(self.id, self.guild_id, self.guild_id, self.channel_id, self.message_id)
@ -40,6 +42,9 @@ def get_channel_messages(guild_id, channel_id, after_snowflake=None):
if x.message_id in snowflakes:
continue
snowflakes.append(x.message_id)
embeds = x.embeds
if not embeds:
embeds = "[]"
message = {
"attachments": json.loads(x.attachments),
"timestamp": x.timestamp,
@ -48,7 +53,8 @@ def get_channel_messages(guild_id, channel_id, after_snowflake=None):
"author": json.loads(x.author),
"content": x.content,
"channel_id": x.channel_id,
"mentions": json.loads(x.mentions)
"mentions": json.loads(x.mentions),
"embeds": json.loads(embeds),
}
member = get_guild_member(guild_id, message["author"]["id"])
message["author"]["nickname"] = None