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:
- Download the lol.py script in the repo above.
- Create a folder to put the
lol.py
script in. - Open a terminal in that folder location.
- In that terminal run the following:
pip install discord.py
- Now edit the
lol.py
script and add the needed values beingDiscord bot token
,server ID
,channel ID
andfolder location of files
.
See the following:
OR:
- Navigate to https://discord.com/developers/applications and click on your application.
- Click on the
Bot
option in the left navbar and make sure to enable the following:Presence Intent
,Server Members Intent
andMessage Content Intent
. - Now click on the
OAuth2
option in the left navbar and copy theClient ID
. - Now open https://discordapi.com/permissions.html in a new browser tab.
- 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
andManage Server
. - Now paste your
Client ID
that you copied in theClient ID:
field at the bottom of the page. - Now click on the link provided at the way bottom of the page.
- Add your bot/application to your chosen server.
- Click Continue.
- 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
-
Wait a min for bot to start up and connect.
-
In your chosen channel send the following command:
!send_files
- 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: