I have a discord bot where the purpose is to take text out of a channel, and save it to two files. When I run it, I see the timestamp for changes to both text files updates, but the text doesn't write to the files. I can see on the logfile a bunch of commas, so I know the bot is reading the messages from discord, but it's not writing them, it is leaving the space blank.
import discord
Templetext = 'writefile.txt'
Logfile = 'templelog.txt'
newline = ('\n')
closetemple = 'exit()'
Token = 'my token string'
client = discord.Client()
print('I am on')
@client.event
async def on_ready():
print('Ready and Listening')
@client.event
async def on_message(message):
with open(Templetext, "w") as file1:
file1.write(f" {message.content}")
with open(Logfile, "a") as file2:
file2.write(f" {message.content}, {newline}")
client.run(Token)