Titan/discordbot/titanembeds/database/messages.py

31 lines
1.6 KiB
Python
Raw Normal View History

2017-05-06 10:03:52 +02:00
from titanembeds.database import db, Base
class Messages(Base):
__tablename__ = "messages"
id = db.Column(db.Integer, primary_key=True) # Auto incremented id
guild_id = db.Column(db.String(255)) # Discord guild id
channel_id = db.Column(db.String(255)) # Channel id
message_id = db.Column(db.String(255)) # Message snowflake
content = db.Column(db.Text()) # Message contents
2017-05-07 02:19:12 +02:00
author = db.Column(db.Text()) # Author json
2017-05-06 10:03:52 +02:00
timestamp = db.Column(db.TIMESTAMP) # Timestamp of when content is created
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
2017-11-05 06:59:06 +01:00
embeds = db.Column(db.Text().with_variant(db.Text(length=4294967295), 'mysql')) # message embeds
2017-05-06 10:03:52 +02:00
2017-11-05 06:59:06 +01:00
def __init__(self, guild_id, channel_id, message_id, content, author, timestamp, edited_timestamp, mentions, attachments, embeds):
2017-05-06 10:03:52 +02:00
self.guild_id = guild_id
self.channel_id = channel_id
self.message_id = message_id
self.content = content
2017-05-07 02:19:12 +02:00
self.author = author
2017-05-06 10:03:52 +02:00
self.timestamp = timestamp
self.edited_timestamp = edited_timestamp
self.mentions = mentions
self.attachments = attachments
2017-11-05 06:59:06 +01:00
self.embeds = embeds
2017-05-06 10:03:52 +02:00
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)