Is it possible to create a TXT file and send it through a webhook?

Hello! I am wondering if it is possible to create a TXT file and send it through a webhook (Discord, for example). Is this possible? I’ve tried researching it and have found nothing.

1 Like

no, not possible at all, can’t send .TXT files to discord lmao

Well, if I’m sending a huge string, is there any other possible way to compress it into a file or something?

Discord has automatic converter for messages longer than 2000 (not sure if it’s exactly this number) characters, there’s no other way to do it.

If you really need a txt file, make a string that you will send through the webhook → discord, but at the end of the string add a lot of characters in a new row or something

1 Like

Thanks! I’ll try this. I’ll mark this as the solution for now, and see if it works later! Thanks, again!

1 Like

This doesn’t work, it rejects my request if its over 2000 characters

1 Like

Yes it’s possible to send text files larger than 2KB to discord if you correctly set the Content-Type, Content-Disposition and request body.

Refer to this

1 Like

I’m not too familiar with roblox-to-discord webhooks. The most complicated thing I’ve ever done with them was make a bot that reports in-game errors. How would I do that? Is there any documentation/tutorial I could read/view? Would it be something like

data = {
    ['content'] = message
    ['content-disposition'] = 'body'

Also, its sending as just a message since I don’t think I can convert it to a .TXT or .MD file. Can I still do that? And how? (Thank you for your help, too! :smiley:)

Take a look at Discord’s documentation for file uploads. The easiest way to do it is to encode the text as multipart/form-data which is not the same as most Discord API endpoints which use JSON.

1 Like

How would I encode it like that?

The request payload would look like:

Content-Disposition: form-data; name="file"; filename="your_filename.txt"
Content-Type: application/octet-stream

[text file contents here]

All of that is in the body of the request, which means those headers are separate from regular HTTP request headers.

So something like this?

data = {
    ["content"] = message
    ["content-disposition"] = {"form-data;", "name="file", "filename="your_filename.txt"}

How would I be able to integrate it in with the rest of my lua code? Like that? The documentation is very generalized, so I don’t know how to list the parameters.

Also how can I do this without getting banned from Discord?

How would I write that in my code?