Skip to content
Advertisement

Discord.py Stuck Trying to Loop Through Logs and Send to Server

I am trying to create a simple discord bot that parses a log file that is constantly being written to and sending the new lines to a discord channel I have on my server name logs.

Parsing the file and printing the output is easy and works just fine. My problem is trying to incorporate it into discord. It seems my program is hanging sometime after connecting and never sends any messages. The bot makes it on the server and completes the on_ready.

I’m brand new to discord.py so I’d appreciate any guidance. Thank you.

JavaScript

Advertisement

Answer

I’m also working on a discord bot with discord.py, so I think I can help you. Here’s how I would do it:

When, the bot is ready, it prints out that he’s logged in

JavaScript

When you want to see whats inside the .txt file, you just have to enter ‘show content’

JavaScript

First it reads the uppermost line

JavaScript

And then deletes it from the file. I know this isn’t the cleanest way and I’m sure there’s a much better solution

JavaScript

Then it’s send the message to your discord channel

JavaScript

Hope this helps :D

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement