/Discord-Bot-Image-Upload

A Script/Bot to upload local files (like images, gifs and videos) to a Discord server channel.

Primary LanguagePython

Discord-Bot-Image-Upload

A Script/Bot to upload local files (like images, gifs and videos) to a Discord server channel.

This bot/script recursively looks for files in a directory, adds them all to a list, sorts that list in chronological order based on Date modified and then sends the files in that order and then the sent file's name gets added to a log file. It also checks a log file (if it already exists) for if a file to be sent has already been sent on the channel and then skips that file if it has already been sent and sends files that have not been sent.

See 'lol.py' for script.

Steps:

  1. Download the lol.py script in the repo above.
  2. Create a folder to put the lol.py script in.
  3. Open a terminal in that folder location.
  4. In that terminal run the following:
  pip install discord.py
  1. Now edit the lol.py script and add the needed values being Discord bot token, server ID, channel ID and folder location of files.

See the following:

OR:

dc bot token

  1. Navigate to https://discord.com/developers/applications and click on your application.
  2. Click on the Bot option in the left navbar and make sure to enable the following: Presence Intent, Server Members Intent and Message Content Intent.
  3. Now click on the OAuth2 option in the left navbar and copy the Client ID.
  4. Now open https://discordapi.com/permissions.html in a new browser tab.
  5. Tick the boxes next to: Administrator, Manage Messages, Manage Channels, Manage Events, Send Messages, Embed Links, Attach Files, Read Message History, Manage Server, View Channels and Manage Server.
  6. Now paste your Client ID that you copied in the Client ID: field at the bottom of the page.
  7. Now click on the link provided at the way bottom of the page.
  8. Add your bot/application to your chosen server.
  9. Click Continue.
  10. Now in the terminal that's in the directory which has your lol.py script run the following to excecute the script/bot:
  python lol.py
  1. Wait a min for bot to start up and connect.

  2. In your chosen channel send the following command:

  !send_files
  1. Now your script/bot should run smoothly and send all the files in the directory you provided while skipping files that was already sent in the channel.

PS:

Discord bot token, server ID and folder location of files should all be enclosed in single qoutations while:

channel ID should not be enclosed in qoutations at all.


SOURCES:

Make Your Own Discord Bot | Basics (2019)