From b43d29bca58751629a1c99365a7fb171b4202be2 Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Sat, 6 May 2017 01:04:34 -0700 Subject: [PATCH] Prevent update msg when no message exists --- discordbot/titanembeds/database/__init__.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/discordbot/titanembeds/database/__init__.py b/discordbot/titanembeds/database/__init__.py index 3b03a80..b68cfa1 100644 --- a/discordbot/titanembeds/database/__init__.py +++ b/discordbot/titanembeds/database/__init__.py @@ -68,8 +68,9 @@ class DatabaseInterface(object): .filter(Messages.guild_id == message.server.id) \ .filter(Messages.channel_id == message.channel.id) \ .filter(Messages.message_id == message.id).first() - msg.content = message.content - msg.edited_timestamp = message.edited_timestamp - msg.mentions = json.dumps(message.mentions) - msg.attachments = json.dumps(message.attachments) - session.commit() + if msg: + msg.content = message.content + msg.edited_timestamp = message.edited_timestamp + msg.mentions = json.dumps(message.mentions) + msg.attachments = json.dumps(message.attachments) + session.commit()