(discord.py) How to send content of a text file as a message

trs-k3tchup

I want my bot to send ascii art. The art is contained in a text file because it's more organized, but when i try to make the bot send it it just sends the file download. I am currently using await ctx.send(file=discord.File('file path')). How do i convert the contents of the file to a string that can be sent as a message?

Poojan

You need to open the txt file read its content and send it

with open("filename.txt") as f:
    content = "\n".join(f.readlines())

await ctx.send(content)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

message.content.startswith Discord.Py

From Dev

how can i make my discord.py bot send a message i choose to a channel i choose?

From Dev

How to send private message to member in on_member_join() discord.py?

From Dev

How do I use discord.py to send a greeting message in the System Messages Channel

From Dev

How do I send a direct message to someone when they join a server with discord.py

From Dev

How would I send all NotifyOSD message to a text file?

From Dev

Discord.py, there is any method do edit a message send by a webhook?

From Dev

Discord.py - Send message under different name or user

From Dev

Sending a message when prefix was send discord.py

From Dev

discord py - Send a different message if a user replies to my bot

From Dev

Send a message and embed with 1 command (Discord.py)

From Dev

How to delete message in discord.py

From Dev

How to send message with discord.js with ID

From Dev

How to send a message to a different server | Discord Bot

From Dev

How to send a colored text message?

From Dev

How to send text message instead of byte message

From Dev

How to send text message instead of byte message

From Dev

JSQMessagesViewController - Send text Message with Attached Images File

From Dev

unable to send both text message and attached file

From Dev

Regarding discord.py's send_file()

From Dev

How to send a DM from a looped event in Discord.py

From Dev

How to remove code syntax from message (discord.py)?

From Dev

How to text message send using timing in android

From Dev

How to send Password Protect SMS/Text Message

From Dev

How do I send a message to a specific channel in discord.js?

From Dev

Discord.py bot.send_message() does not go to the channel it has been called at

From Dev

How to send file content in distributed environment?

From Dev

How to send the content in the json file to the frontend?

From Dev

send text message with applescript

Related Related

  1. 1

    message.content.startswith Discord.Py

  2. 2

    how can i make my discord.py bot send a message i choose to a channel i choose?

  3. 3

    How to send private message to member in on_member_join() discord.py?

  4. 4

    How do I use discord.py to send a greeting message in the System Messages Channel

  5. 5

    How do I send a direct message to someone when they join a server with discord.py

  6. 6

    How would I send all NotifyOSD message to a text file?

  7. 7

    Discord.py, there is any method do edit a message send by a webhook?

  8. 8

    Discord.py - Send message under different name or user

  9. 9

    Sending a message when prefix was send discord.py

  10. 10

    discord py - Send a different message if a user replies to my bot

  11. 11

    Send a message and embed with 1 command (Discord.py)

  12. 12

    How to delete message in discord.py

  13. 13

    How to send message with discord.js with ID

  14. 14

    How to send a message to a different server | Discord Bot

  15. 15

    How to send a colored text message?

  16. 16

    How to send text message instead of byte message

  17. 17

    How to send text message instead of byte message

  18. 18

    JSQMessagesViewController - Send text Message with Attached Images File

  19. 19

    unable to send both text message and attached file

  20. 20

    Regarding discord.py's send_file()

  21. 21

    How to send a DM from a looped event in Discord.py

  22. 22

    How to remove code syntax from message (discord.py)?

  23. 23

    How to text message send using timing in android

  24. 24

    How to send Password Protect SMS/Text Message

  25. 25

    How do I send a message to a specific channel in discord.js?

  26. 26

    Discord.py bot.send_message() does not go to the channel it has been called at

  27. 27

    How to send file content in distributed environment?

  28. 28

    How to send the content in the json file to the frontend?

  29. 29

    send text message with applescript

HotTag

Archive