I am trying to create a simple bot for a discord server in Python. For now, as a joke, I am just trying to create a "report" command that will send the entire Bee Movie script to whoever types that.
For some reason, whenever I try to do await message.channel.send(line.strip())
I get an "invalid syntax error"
Does anyone have any tips on how to solve this issue?
# bot.py
import os
import discord
from dotenv import load_dotenv
load_dotenv()
TOKEN = os.getenv('TOKEN')
client = commands.Bot(command_prefix ='$')
def read_lines(file):
with open(file, 'rb') as f:
lines = f.readlines()
for line in lines:
if line == "\n":
print("\nEmpty Line\n")
else:
await message.channel.send(line.strip())
return
@client.event
async def on_ready():
print(f'{client.user} has connected to Discord!')
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('$hello'):
await message.channel.send('Hello!')
if message.content.startswith('$report'):
read_lines('bot.txt')
client.run(TOKEN)
P.S: I am fairly new to Python and the return
right after the mentioned line is also giving me an indentation block issue