Skip to content Skip to sidebar Skip to footer

Python Discord.py Ways To Split Output To Bypass 2000 Character Limit

I am attempting to output the contents of a text file to a discord channel via Discord. The issue I have is that there is a 2000 character limit. I have been able to bypass this by

Solution 1:

Is there a reason you can't just do your read and your send separately and check if the read result is empty before you do your send?

with open('/home/brendan/Desktop/englishfootball.txt', 'r') as file:
    msg = file.read(2000).strip()
    while len(msg) > 0:
        await message.channel.send(msg)
        msg = file.read(2000).strip()

Post a Comment for "Python Discord.py Ways To Split Output To Bypass 2000 Character Limit"