Darkempire78 / Raid-Protect-Discord-Bot

A Discord Bot that allows you to protect your Discord server with captcha, anti profanity, anti nudity image, anti spam, account age required, logs...
GNU General Public License v3.0
229 stars 74 forks source link

Send the captcha without saving it #1

Open Astremy opened 4 years ago

Astremy commented 4 years ago

https://github.com/Darkempire78/Raid-Protect-Discord-Bot/blob/1c3699b1eb38da638e35c3085ed7e3a640126e8b/Cogs/onJoin.py#L119

Here, you create a file to send your image, don't do that !

You can just send data, without use a file. Additionally, you delete the file only if the user have the correct answer in 120 s. Your bot will then automatically take up disk space until there is no more disk space left.

Darkempire78 commented 4 years ago

Thanks for your informations.

I have change the script. Now the bot delete the captcha folder just after the captcha sending. You said to send directly the image content and do not save it, but it's create an error : TypeError: expected str, bytes or os.PathLike object, not PngImageFile.

I will search better to convert in a good format.

Astremy commented 4 years ago

Here is an explaination for how to upload an image :

https://discordpy.readthedocs.io/en/latest/faq.html#how-do-i-upload-an-image

TheOnlyWayUp commented 2 years ago

You can save to bytesio, https://stackoverflow.com/a/65496569/12107639 has more info about sending