From 9ae69b9e1465e082267f3d00de84466d44617cac Mon Sep 17 00:00:00 2001 From: sgoudham Date: Wed, 24 Jun 2020 01:57:25 +0100 Subject: [PATCH] Fixed dm messages Checking to see if dm-logs work on heroku --- EnsoBot.py | 10 +++++----- images/logs/dm-logs.txt | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/EnsoBot.py b/EnsoBot.py index 25a7f464..1f1cf087 100644 --- a/EnsoBot.py +++ b/EnsoBot.py @@ -269,9 +269,9 @@ async def on_message(message): # Send message to #general channel = client.get_channel(721449922838134876) await channel.send(message.content) - write_to_file(msg_time, msg_author, msg_content) + write_to_dm_file(msg_time, msg_author, msg_content) else: - write_to_file(msg_time, msg_author, msg_content) + write_to_dm_file(msg_time, msg_author, msg_content) await client.process_commands(message) @@ -322,9 +322,9 @@ async def on_command_missing_user(ctx): await message.delete() -def write_to_file(time, author, content): - with open('images/logs/dm-logs.txt', mode='w') as dm_logs_file: - dm_logs_file.write(f"{time}: {author}: {content}\n") +def write_to_dm_file(time, author, content): + with open('images/logs/dm-logs.txt', mode='a') as dm_logs_file: + dm_logs_file.write(f"{time}: {author}: {content}") # Run the bot, allowing it to come online diff --git a/images/logs/dm-logs.txt b/images/logs/dm-logs.txt index 0f7d9bff..3cd88f15 100644 --- a/images/logs/dm-logs.txt +++ b/images/logs/dm-logs.txt @@ -1 +1,2 @@ -2020-06-24T00:47:47.401000: Mr. Hamothy#5619: Testing \ No newline at end of file +2020-06-24T00:54:12.116000: Mr. Hamothy#5619: sdfds +2020-06-24T00:55:02.451000: Mr. Hamothy#5619: Hiiii \ No newline at end of file