Skip to content
Advertisement

Make Discord BOT get random image from a ftp server (Filezilla)

I’m just gonna say it right away that I have no experience whatsoever in python. I’m trying to make a bot for a private Discord server that posts a random image (.jpg) from a ftp server (root directory) after typing ‘$gimme’. #file names are random jibberish

I’ve searched for hours to find a solution but I always get stuck at something. I can’t figure out the syntax of ftp in conjunction with discord since my knowledge of python is as close to non-existent as it gets and no matter how much I search for an answer I can’t figure it out.

This is really my last option, I have nowhere else to look for. I hope someone with a little bit more knowledge than me can help me out.

Thank You

JavaScript

Advertisement

Answer

EDIT with the callback method

I know python and FTP not discord but by looking at the docs I found how to send a file in discord. I made the following code (without test). I add a function which randomly get a file from FTP the server and call this function in the on_message function

JavaScript

To optimize :

  • Ensure the file is downloaded (with try catch block)
  • Ensure the downloaded file is an image (with the MIMETYPE)
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement