Answer the question
In order to leave comments, you need to log in
How to send text from a file?
We need the bot to send a message with the text taken from the .txt file
. I wrote the following code:
@client.event
async def on_message(message):
msg = message.content.lower()
await client.process_commands(message) # чтобы работали команды с префиксам
if message.author.bot: # Игнорит сообщения от ботов
return
if msg in report_words:
with open(f'{getcwd()}\почему.txt', 'r') as file:
text = file.read()
await message.channel.send(text)
<_io.TextIOWrapper name='D:\path to file\why.txt' mode='r' encoding='cp1251'>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question