Sapphire Images allows you to upload images and get URLs that permanently point to these images right within Discord.
Images uploaded to Discord get a new image link every few weeks since Feburary 2024.
This means that images uploaded to Discord can no longer be used as Moderation proof. Sapphire Images aims to fix that.
- Discord bot
- Command /upload-image allows you to upload an image
- Auto-upload images attached to messages with the bot being mentioned (@bot)
- Auto-upload images sent in set channels
- Web server
- Endpoint /upload allows image uploads (optionally with auth)
- Serves images uploaded using the bot or the upload endpoint
- Storage methods:
- Local - Stores images in set folder
- Cloudflare - Uploads images to Cloudflare Images
- More aren't planned but feel free to add them yourself, I am happy to merge any useful pull requests!
Follow the steps below to set up Sapphire Images. It was only tested in a Linux environment.
git clone https://github.com/Sapphire-Discord-Bot/images
cd images
npm install
mv _.env .env
DISCORD_TOKEN
: Set your Discord bot token (How to obtain a token?)UPLOAD_TOKEN
: Set to random characters to prevent people from uploading images through the web without authSTORE_METHOD
: Set to your preferred image store method (How to set up each method?)
npm start
Replace the file located in ./static/icons/logo.png
.
Edit the values of the properties below # Customization texts
inside ./.env
.
- Go to the Discord Developer Portal.
- Create a new application.
- Once created, go to your application's "Bot" tab.
- Click "Reset token" and store the token somewhere safe.
Store images inside a set folder.
- Set
STORE_LOCAL_PATH
to the folder path you want uploaded images to go. Make sure the folder is created.
Store images using Cloudflare's Images service.
- Go to Cloudflare Images.
- Click "Sign up for Cloudflare Images".
- Once logged in, choose a paid plan that fits your needs (starting at $5/month).
- Make sure to enable storage when subscribing, otherwise this store method won't work.
- Once subscribed, locate your Account ID and Image Delivery URL.
- Set
STORE_CF_ID
to your Account ID. - Set
STORE_CF_DELIVERY_URL
to your Image Delivery URL, make sure to leave out/<image_id>/<variant_name>
and end your URL with a slash.- For example:
STORE_CF_DELIVERY_URL=https://imagedelivery.net/kOobDSmCCUYL7kOnWLrX4M/
- For example:
- Go to your Cloudflare API tokens.
- Create a token and choose "Custom token".
- Name your token and set permissions to
Read
andEdit
Account > Cloudflare Images
. - Once your token is created, set
STORE_CF_TOKEN
to your just created token.