Table of Contents
Convert images to urls using discord bot / imgbb api
- How it works
For discord:
Images are sent to a discord channel that you specify.
The bot will then get the proxy url of the image and then return it to you.
For imgbb:
Images are sent to imgbb database and then the url is returned to you.
For Discord
- Make a discord bot in discord developer portal
- Copy the token and paste it in the .env file named
DISCORD_TOKEN
- Invite the bot to your server
- Get the channel id of the channel where you want to send the images
- Paste the channel id in the .env file named
DISCORD_CHANNEL
- Check env_example file for more info - env_example
- Install the required packages -
discord.js, dotenv, fs
- Install image2url using npm
npm install image2url
- Require the package in your main file
const image2url = require('image2url');
For Imgbb
- Make an account on imgbb
- Get the api key from the dashboard
- Paste the api key in the .env file named
IMG_BB_KEY
- Install the required packages -
axios, dotenv, fs, form-data
// Discord upload
image2url.init({
token: process.env.DISCORD_TOKEN,
channel: process.env.DISCORD_CHANNEL
});
image2url.upload('tests/kurizu.jpg', 'kurizu pfp').then(url => {
console.log(url);
});
// Imgbb upload
const imagePath = 'tests/kurizu.jpg';
image2url.imgbb_upload(imagePath, process.env.IMG_BB_KEY)
.then((url) => {
console.log('Image uploaded successfully. URL:', url);
})
.catch((error) => {
console.error('Image upload failed with error:', error);
});
Check env_example file for more info - env_example
const image2url = require('image2url');
require('dotenv').config()
// Discord upload
image2url.init({
token: process.env.DISCORD_TOKEN,
channel: process.env.DISCORD_CHANNEL
});
image2url.upload('tests/kurizu.jpg', 'kurizu pfp').then(url => {
console.log(url);
});
// Imgbb upload
const imagePath = 'tests/kurizu.jpg';
image2url.imgbb_upload(imagePath, process.env.IMG_BB_KEY)
.then((url) => {
console.log('Image uploaded successfully. URL:', url);
})
.catch((error) => {
console.error('Image upload failed with error:', error);
});
Note:
- tests/kurizu.jpg is the path to the image you want to send.
- kurizu pfp is the name of the image.
- The url will have the name that you specified. which in this case is kurizu pfp.
- Add Changelog
- Add Tests
- Add Additional Templates w/ Examples
- Add Support for more image formats
- Documentation
- Website
- Examples
- Wiki
- Add Support for more platforms
See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt
for more information.
Package Made by: kurizu.taz
on discord
Github - https://github.com/crizmo/image2url